]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
util: Fix exec_alt
authorSimon Wilkinson <sxw@your-file-system.com>
Sun, 20 Mar 2011 21:13:09 +0000 (21:13 +0000)
committerDerrick Brashear <shadow@dementia.org>
Wed, 23 Mar 2011 18:29:37 +0000 (11:29 -0700)
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 <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
(cherry picked from commit 8c418408016ff8d6be9f85c4666a49954f61dbd0)

Change-Id: Ie34832eb94f91a6e9083f65aa81333cb7b1fbb30
Reviewed-on: http://gerrit.openafs.org/4279
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementia.org>
src/util/exec.c

index cd84cd9fc78ae8b8ae858557f801ef9203f47a71..df8722e7fd1cd8dc3dfcd7d033e0f998e105a482 100644 (file)
@@ -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;
 }