Commit 73d1c580 authored by Jerry James's avatar Jerry James Committed by Masahiro Yamada

kconfig: loop boundary condition fix

If buf[-1] just happens to hold the byte 0x0A, then nread can wrap around
to (size_t)-1, leading to invalid memory accesses.

This has caused segmentation faults when trying to build the latest
kernel snapshots for i686 in Fedora:
https://bugzilla.redhat.com/show_bug.cgi?id=1592374Signed-off-by: default avatarJerry James <loganjerry@gmail.com>
[alexpl@fedoraproject.org: reformatted patch for submission]
Signed-off-by: default avatarAlexander Ploumistos <alexpl@fedoraproject.org>
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
parent 8b9d2712
...@@ -156,7 +156,7 @@ static char *do_shell(int argc, char *argv[]) ...@@ -156,7 +156,7 @@ static char *do_shell(int argc, char *argv[])
nread--; nread--;
/* remove trailing new lines */ /* remove trailing new lines */
while (buf[nread - 1] == '\n') while (nread > 0 && buf[nread - 1] == '\n')
nread--; nread--;
buf[nread] = 0; buf[nread] = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment