From: Simon Wilkinson Date: Sun, 20 Mar 2011 21:13:09 +0000 (+0000) Subject: util: Fix exec_alt X-Git-Tag: upstream/1.6.0.pre4^2~26 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=35451a9d436d6359faab933fd2432b84f5dddf8e;p=packages%2Fo%2Fopenafs.git util: Fix exec_alt exec_alt was failing its tests on Mac OS X (but passing them on Linux). It turns out that this is because it was failing to NULL terminate the string that it creates in construct_alt(), which copies in the characters from argv0, prefix and suffix, but never copies in a trailing NULL. Amend the code so that the trailing NULL from suffix is used to terminate the string. Reviewed-on: http://gerrit.openafs.org/4267 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Derrick Brashear (cherry picked from commit 8c418408016ff8d6be9f85c4666a49954f61dbd0) Change-Id: Ie34832eb94f91a6e9083f65aa81333cb7b1fbb30 Reviewed-on: http://gerrit.openafs.org/4279 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/util/exec.c b/src/util/exec.c index cd84cd9fc..df8722e7f 100644 --- a/src/util/exec.c +++ b/src/util/exec.c @@ -45,7 +45,7 @@ construct_alt(const char *argv0, const char *prefix, const char *suffix) memmove(replace + prefix_len, replace, replace_len); memcpy(replace, prefix, prefix_len); /* basically strcat(replace, suffix), but a touch faster */ - memcpy(replace + prefix_len + replace_len, suffix, suffix_len); + memcpy(replace + prefix_len + replace_len, suffix, suffix_len + 1); return alt; }