Increase the realloc increment from 128 to 1024.

The contents of the env_add array should not include the leading
"env=" prefix.
This commit is contained in:
Todd C. Miller
2022-07-09 09:02:25 -06:00
parent 224d78993a
commit e7b7fbaf6e

View File

@@ -118,13 +118,13 @@ push(struct dynamic_array *arr, const char *entry)
} }
if (arr->len + (entry != NULL) >= arr->size) { if (arr->len + (entry != NULL) >= arr->size) {
char **tmp = reallocarray(arr->entries, arr->size + 128, sizeof(char *)); char **tmp = reallocarray(arr->entries, arr->size + 1024, sizeof(char *));
if (tmp == NULL) { if (tmp == NULL) {
free(copy); free(copy);
return false; return false;
} }
arr->entries = tmp; arr->entries = tmp;
arr->size += 128; arr->size += 1024;
} }
if (copy != NULL) if (copy != NULL)
arr->entries[arr->len++] = copy; arr->entries[arr->len++] = copy;
@@ -372,6 +372,8 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
/* Additional environment variables to add. */ /* Additional environment variables to add. */
if (strncmp(line, "env=", sizeof("env=") - 1) == 0) { if (strncmp(line, "env=", sizeof("env=") - 1) == 0) {
const char *cp = line + sizeof("env=") - 1;
if (strchr(cp, '=') != NULL)
push(&env_add, line); push(&env_add, line);
continue; continue;
} }