Skip to content

Commit

Permalink
init: Fix memory corruption when sanitizing platform paths
Browse files Browse the repository at this point in the history
This commit fixes code that incorrectly increments s when it
hits the terminator character of the string being sanitized.
This means it will randomly start trashing memory beyond the
end of the string being sanitized until it happens to hit two
NULs (\0\0) which will break it out of the loop.

Change-Id: I76553d7f183236a78a0bc7b408e92559b98f732f
  • Loading branch information
crpalmer committed Sep 22, 2014
1 parent d21de8c commit 44a46d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions init/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ void sanitize(char *s)
if (!s)
return;

for (; *s; s++) {
while (*s) {
s += strspn(s, accept);
if (*s) *s = '_';
if (*s) *s++ = '_';
}
}

Expand Down

0 comments on commit 44a46d6

Please sign in to comment.