summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJerry James <loganjerry@gmail.com>2018-06-23 22:49:04 +0200
committerMasahiro Yamada <yamada.masahiro@socionext.com>2018-06-28 22:48:08 +0900
commit73d1c580f92b203f4c3a189ee98c917c65712f7e (patch)
treef5f4a1a5b4d02a109a2a60feec525d8a5aeb39eb /scripts
parent8b9d27124094964b3c4f8985ba66355ac4d9e842 (diff)
downloadlinux-73d1c580f92b203f4c3a189ee98c917c65712f7e.tar.bz2
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>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kconfig/preprocess.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/kconfig/preprocess.c b/scripts/kconfig/preprocess.c
index 65da87fce907..5ca2df790d3c 100644
--- a/scripts/kconfig/preprocess.c
+++ b/scripts/kconfig/preprocess.c
@@ -156,7 +156,7 @@ static char *do_shell(int argc, char *argv[])
nread--;
/* remove trailing new lines */
- while (buf[nread - 1] == '\n')
+ while (nread > 0 && buf[nread - 1] == '\n')
nread--;
buf[nread] = 0;