diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2017-06-27 11:59:32 +0200 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2017-07-14 13:47:31 +0100 |
commit | 213b279baaae27a4285eb354f11e3c3b1986d129 (patch) | |
tree | 95770a571f11fbce82fbc5b91f6ce1ffe0860985 /scripts | |
parent | 32fb4fe097115b23914832d26dba4d1de62f5f17 (diff) | |
download | busybox-w32-213b279baaae27a4285eb354f11e3c3b1986d129.tar.gz busybox-w32-213b279baaae27a4285eb354f11e3c3b1986d129.tar.bz2 busybox-w32-213b279baaae27a4285eb354f11e3c3b1986d129.zip |
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 <johannes.schindelin@gmx.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/basic/fixdep.c | 5 |
1 files changed, 4 insertions, 1 deletions
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) | |||
389 | m++; | 389 | m++; |
390 | p = m; | 390 | p = m; |
391 | while (p < end && *p != ' ') p++; | 391 | while (p < end && *p != ' ') p++; |
392 | if (p == m) break; | ||
392 | if (p == end) { | 393 | if (p == end) { |
393 | do p--; while (!isalnum(*p)); | 394 | do p--; while (p != m && !isalnum(*p)); |
394 | p++; | 395 | p++; |
395 | } | 396 | } |
397 | if (p == m) break; | ||
396 | memcpy(s, m, p-m); s[p-m] = 0; | 398 | memcpy(s, m, p-m); s[p-m] = 0; |
397 | if (strrcmp(s, "include/autoconf.h") && | 399 | if (strrcmp(s, "include/autoconf.h") && |
398 | strrcmp(s, "arch/um/include/uml-config.h") && | 400 | strrcmp(s, "arch/um/include/uml-config.h") && |
@@ -400,6 +402,7 @@ void parse_dep_file(void *map, size_t len) | |||
400 | printf(" %s \\\n", s); | 402 | printf(" %s \\\n", s); |
401 | do_config_file(s); | 403 | do_config_file(s); |
402 | } | 404 | } |
405 | if (p == end) break; | ||
403 | m = p + 1; | 406 | m = p + 1; |
404 | } | 407 | } |
405 | printf("\n%s: $(deps_%s)\n\n", target, target); | 408 | printf("\n%s: $(deps_%s)\n\n", target, target); |