Skip to content

Commit

Permalink
Fix off-by-one in buffer length in int_to_env
Browse files Browse the repository at this point in the history
We need to allow for '=', negative sign, 10 digits and the null
terminator, adding up to 13 bytes not 12.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
  • Loading branch information
bwhacks committed Jan 28, 2016
1 parent a6bbd1d commit 6296859
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/script.c
Expand Up @@ -227,7 +227,7 @@ static void search_to_env(const char *name, const uint8_t *start, size_t len)

static void int_to_env(const char *name, int value)
{
size_t len = 12 + strlen(name);
size_t len = 13 + strlen(name);
char *buf = realloc(NULL, len);
snprintf(buf, len, "%s=%d", name, value);
putenv(buf);
Expand Down

0 comments on commit 6296859

Please sign in to comment.