[git commit] uudecode: tolerate text input with CR+LF line ends

Denys Vlasenko vda.linux at googlemail.com
Mon Oct 5 13:10:44 UTC 2015


commit: http://git.busybox.net/busybox/commit/?id=2b48c38be60cf9033761365f40c05f2e6a41a1c4
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
read_stduu                                           265     308     +43
uudecode_main                                        313     317      +4

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 coreutils/uudecode.c          |   13 ++++++++++++-
 qemu_multiarch_testing/README |   19 +++++++------------
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c
index 7aa5c67..37b254d 100644
--- a/coreutils/uudecode.c
+++ b/coreutils/uudecode.c
@@ -29,9 +29,19 @@ static void FAST_FUNC read_stduu(FILE *src_stream, FILE *dst_stream, int flags U
 {
 	char *line;
 
-	while ((line = xmalloc_fgetline(src_stream)) != NULL) {
+	for (;;) {
 		int encoded_len, str_len;
 		char *line_ptr, *dst;
+		size_t line_len;
+
+		line_len = 64 * 1024;
+		line = xmalloc_fgets_str_len(src_stream, "\n", &line_len);
+		if (!line)
+			break;
+		/* Handle both Unix and MSDOS text, and stray trailing spaces */
+		str_len = line_len;
+		while (--str_len >= 0 && isspace(line[str_len]))
+			line[str_len] = '\0';
 
 		if (strcmp(line, "end") == 0) {
 			return; /* the only non-error exit */
@@ -128,6 +138,7 @@ int uudecode_main(int argc UNUSED_PARAM, char **argv)
 			if (!outname)
 				break;
 			outname++;
+			trim(outname); /* remove trailing space (and '\r' for DOS text) */
 			if (!outname[0])
 				break;
 		}
diff --git a/qemu_multiarch_testing/README b/qemu_multiarch_testing/README
index 69ddb76..9757ff0 100644
--- a/qemu_multiarch_testing/README
+++ b/qemu_multiarch_testing/README
@@ -33,7 +33,7 @@ You can also run "./parallel-build-hdc-img.sh -s system-image-ARCH"
 - single mode, output is to screen and serial input is from keyboard.
 
 If hdc.dir/bin/busybox-$ARCH exists, it will be used during build
-to supply additional tools.
+to supply additional tools (dir with all applets appended to $PATH).
 
 For me, the following system images worked:
 system-image-armv4l
@@ -42,22 +42,17 @@ system-image-armv5l
     od is buggy on arm*:
     # echo Hello-hello-hello-hello | od -b
     0000000 110 145 154 154 157 055 150 145 154 154 157 055 150 145 154 154
-    0000000 157 055 150 145 154 154 157 012
-    0000000
+    0000000 157 055 150 145 154 154 157 012  <= WRONG OFFSET
+    0000000                     (can also be even more bogus like 17767153361)
 system-image-i686
-system-image-mips
-system-image-mipsel
-    od is buggy on mips[el]:
-    # echo Hello-hello-hello-hello | od -b
-    0000000 110 145 154 154 157 055 150 145 154 154 157 055 150 145 154 154
-    17767153361 157 055 150 145 154 154 157 012
-    0000000
+system-image-mips    - od is buggy
+system-image-mipsel  - od is buggy
 system-image-x86_64
+system-image-powerpc - qemu 1.2.2 didn't work, 2.4.0 worked; od is buggy
+system-image-sparc   - qemu 1.2.2 didn't work, 2.4.0 worked; od is buggy
 
 And these did not:
 system-image-armv6l  - hang on "Uncompressing Linux... done, booting the kernel"
-system-image-powerpc - hang early in kernel boot
-system-image-sparc   - hang early in userspace
 system-image-m68k    - my qemu doesn't like "-M q800"
 system-image-mips64  - init dies "Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000a"
 system-image-sh4     - qemu segfaults early in kernel boot


More information about the busybox-cvs mailing list