From 213b279baaae27a4285eb354f11e3c3b1986d129 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 27 Jun 2017 11:59:32 +0200 Subject: fixdep: be careful about handling empty lines correctly The current code without this patch is seriously flawed, as it can easily overrun the buffer while looking for the *beginning* of the line. The symptom when trying to build without this patch in Git for Windows' SDK (which is a special-purpose version of MSYS2) is: $ make mingw64_defconfig && make -j15 HOSTCC scripts/basic/fixdep make[1]: *** [scripts/Makefile.host:104: scripts/basic/fixdep] Error 127 make: *** [Makefile:358: scripts_basic] Error 2 make: *** [Makefile:358: scripts_basic] Error 2 Signed-off-by: Johannes Schindelin --- scripts/basic/fixdep.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 7bb808b9e..d3aa4e390 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -389,10 +389,12 @@ void parse_dep_file(void *map, size_t len) m++; p = m; while (p < end && *p != ' ') p++; + if (p == m) break; if (p == end) { - do p--; while (!isalnum(*p)); + do p--; while (p != m && !isalnum(*p)); p++; } + if (p == m) break; memcpy(s, m, p-m); s[p-m] = 0; if (strrcmp(s, "include/autoconf.h") && strrcmp(s, "arch/um/include/uml-config.h") && @@ -400,6 +402,7 @@ void parse_dep_file(void *map, size_t len) printf(" %s \\\n", s); do_config_file(s); } + if (p == end) break; m = p + 1; } printf("\n%s: $(deps_%s)\n\n", target, target); -- cgit v1.2.3-55-g6feb