Skip to content

Commit

Permalink
utils: Fix out-of-bounds write
Browse files Browse the repository at this point in the history
We are adding terminating NUL into res[len]. To avoid the invalid write, let's allocate len + 1.

Fixes: ebassi/graphene#168
  • Loading branch information
jtojnar committed Aug 25, 2019
1 parent 822b5dd commit 5f565f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/mutest-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ string_split (const char *str,
indent[indent_len] = '\0';
}

char *res = malloc (sizeof (char) * len);
char *res = malloc (sizeof (char) * (len + 1));
if (mutest_unlikely (res == NULL))
mutest_oom_abort ();

Expand Down

0 comments on commit 5f565f2

Please sign in to comment.