]> git.cworth.org Git - fips/commitdiff
Fix 3 separate off-by-one error in as many lines of code.
authorCarl Worth <cworth@cworth.org>
Thu, 25 Apr 2013 05:52:50 +0000 (22:52 -0700)
committerCarl Worth <cworth@cworth.org>
Thu, 25 Apr 2013 05:52:50 +0000 (22:52 -0700)
This one is quite embarrassing, and is evidence that I should have
gone to bead earlier last night.

execute.c

index bf576acf318abf683432cab68c877b7d3f4bf278..68a60bfedf9f918cdb553f60c4a8150bbdec4946 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -77,20 +77,20 @@ get_bin_name (void *ctx)
         * of the filename being linked to). Go figure. */
        int name_len = PATH_MAX + 1;
 
-       name = talloc_size (ctx, name_len - 1);
+       name = talloc_size (ctx, name_len);
        if (name == NULL) {
                fprintf (stderr, "Out of memory.\n");
                exit (1);
        }
 
-       name_len = readlink (link, name, name_len);
+       name_len = readlink (link, name, name_len - 1);
        if (name_len < 0) {
                fprintf (stderr, "Failed to readlink %s: %s\n", link,
                         strerror (errno));
                exit (1);
        }
 
-       name[name_len + 1] = '\0';
+       name[name_len] = '\0';
 
        return name;
 }