From: Carl Worth Date: Thu, 25 Apr 2013 05:52:50 +0000 (-0700) Subject: Fix 3 separate off-by-one error in as many lines of code. X-Git-Url: https://git.cworth.org/git?p=fips;a=commitdiff_plain;h=11b56832eafd3a37e7a9f92bc0f19fbdc187ffac Fix 3 separate off-by-one error in as many lines of code. This one is quite embarrassing, and is evidence that I should have gone to bead earlier last night. --- diff --git a/execute.c b/execute.c index bf576ac..68a60bf 100644 --- 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; }