From ce9a1568d11d3f93b5a1535067029e8262ca0a04 Mon Sep 17 00:00:00 2001 From: comex Date: Sat, 11 Apr 2015 23:18:35 -0400 Subject: More bugfixes thanks to him. --- darwin-bootstrap/bundle-loader.c | 2 ++ darwin-bootstrap/posixspawn-hook.c | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'darwin-bootstrap') diff --git a/darwin-bootstrap/bundle-loader.c b/darwin-bootstrap/bundle-loader.c index 754bd5c..b3c60d5 100644 --- a/darwin-bootstrap/bundle-loader.c +++ b/darwin-bootstrap/bundle-loader.c @@ -227,6 +227,8 @@ static void init() { return; } const char *argv0 = (*_NSGetArgv())[0]; + if (!argv0) + argv0 = "???"; void *bundle_list; size_t bundle_list_size; kr = substituted_hello(service, SUBSTITUTED_PROTO_VERSION, argv0, diff --git a/darwin-bootstrap/posixspawn-hook.c b/darwin-bootstrap/posixspawn-hook.c index ee6a1cb..d2a79f4 100644 --- a/darwin-bootstrap/posixspawn-hook.c +++ b/darwin-bootstrap/posixspawn-hook.c @@ -241,14 +241,15 @@ static int hook_posix_spawn_generic(__typeof__(posix_spawn) *old, /* append if it isn't one of ours */ bool is_substitute = (next - p == sizeof(bl_dylib) - 1 && - !memcmp(next, bl_dylib, sizeof(bl_dylib) - 1)) || + !memcmp(p, bl_dylib, sizeof(bl_dylib) - 1)) || (next - p == sizeof(psh_dylib) - 1 && - !memcmp(next, psh_dylib, sizeof(psh_dylib) - 1)); + !memcmp(p, psh_dylib, sizeof(psh_dylib) - 1)); if (!is_substitute) { if (newp != newp_orig) *newp++ = ':'; memcpy(newp, p, next - p); newp += next - p; + *newp = '\0'; } if (!*next) break; -- cgit v1.2.3