Skip to content

Commit 73d1c58

Browse files
jamesjermasahir0y
authored andcommitted
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=1592374 Signed-off-by: Jerry James <loganjerry@gmail.com> [alexpl@fedoraproject.org: reformatted patch for submission] Signed-off-by: Alexander Ploumistos <alexpl@fedoraproject.org> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent 8b9d271 commit 73d1c58

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/kconfig/preprocess.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static char *do_shell(int argc, char *argv[])
156156
nread--;
157157

158158
/* remove trailing new lines */
159-
while (buf[nread - 1] == '\n')
159+
while (nread > 0 && buf[nread - 1] == '\n')
160160
nread--;
161161

162162
buf[nread] = 0;

0 commit comments

Comments
 (0)