Fix off-by-one in buffer length in int_to_env
authorBen Hutchings <ben@decadent.org.uk>
Fri, 22 Jan 2016 19:07:52 +0000 (19:07 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 28 Jan 2016 13:30:14 +0000 (13:30 +0000)
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>
src/script.c

index 83fbea5..89cb0d6 100644 (file)
@@ -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);