diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-05 15:10:44 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-05 15:10:44 +0200 |
commit | 2b48c38be60cf9033761365f40c05f2e6a41a1c4 (patch) | |
tree | dba36ba4da34d117174f04742e9a60b2cb6fb873 | |
parent | e6b578761a77a9b8d073b6b33a3c4e3d175a7c37 (diff) | |
download | busybox-w32-2b48c38be60cf9033761365f40c05f2e6a41a1c4.tar.gz busybox-w32-2b48c38be60cf9033761365f40c05f2e6a41a1c4.tar.bz2 busybox-w32-2b48c38be60cf9033761365f40c05f2e6a41a1c4.zip |
uudecode: tolerate text input with CR+LF line ends
function old new delta
read_stduu 265 308 +43
uudecode_main 313 317 +4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | coreutils/uudecode.c | 13 | ||||
-rw-r--r-- | qemu_multiarch_testing/README | 19 |
2 files changed, 19 insertions, 13 deletions
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c index 7aa5c67f2..37b254d30 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 | |||
29 | { | 29 | { |
30 | char *line; | 30 | char *line; |
31 | 31 | ||
32 | while ((line = xmalloc_fgetline(src_stream)) != NULL) { | 32 | for (;;) { |
33 | int encoded_len, str_len; | 33 | int encoded_len, str_len; |
34 | char *line_ptr, *dst; | 34 | char *line_ptr, *dst; |
35 | size_t line_len; | ||
36 | |||
37 | line_len = 64 * 1024; | ||
38 | line = xmalloc_fgets_str_len(src_stream, "\n", &line_len); | ||
39 | if (!line) | ||
40 | break; | ||
41 | /* Handle both Unix and MSDOS text, and stray trailing spaces */ | ||
42 | str_len = line_len; | ||
43 | while (--str_len >= 0 && isspace(line[str_len])) | ||
44 | line[str_len] = '\0'; | ||
35 | 45 | ||
36 | if (strcmp(line, "end") == 0) { | 46 | if (strcmp(line, "end") == 0) { |
37 | return; /* the only non-error exit */ | 47 | return; /* the only non-error exit */ |
@@ -128,6 +138,7 @@ int uudecode_main(int argc UNUSED_PARAM, char **argv) | |||
128 | if (!outname) | 138 | if (!outname) |
129 | break; | 139 | break; |
130 | outname++; | 140 | outname++; |
141 | trim(outname); /* remove trailing space (and '\r' for DOS text) */ | ||
131 | if (!outname[0]) | 142 | if (!outname[0]) |
132 | break; | 143 | break; |
133 | } | 144 | } |
diff --git a/qemu_multiarch_testing/README b/qemu_multiarch_testing/README index 69ddb76b8..9757ff0e4 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" | |||
33 | - single mode, output is to screen and serial input is from keyboard. | 33 | - single mode, output is to screen and serial input is from keyboard. |
34 | 34 | ||
35 | If hdc.dir/bin/busybox-$ARCH exists, it will be used during build | 35 | If hdc.dir/bin/busybox-$ARCH exists, it will be used during build |
36 | to supply additional tools. | 36 | to supply additional tools (dir with all applets appended to $PATH). |
37 | 37 | ||
38 | For me, the following system images worked: | 38 | For me, the following system images worked: |
39 | system-image-armv4l | 39 | system-image-armv4l |
@@ -42,22 +42,17 @@ system-image-armv5l | |||
42 | od is buggy on arm*: | 42 | od is buggy on arm*: |
43 | # echo Hello-hello-hello-hello | od -b | 43 | # echo Hello-hello-hello-hello | od -b |
44 | 0000000 110 145 154 154 157 055 150 145 154 154 157 055 150 145 154 154 | 44 | 0000000 110 145 154 154 157 055 150 145 154 154 157 055 150 145 154 154 |
45 | 0000000 157 055 150 145 154 154 157 012 | 45 | 0000000 157 055 150 145 154 154 157 012 <= WRONG OFFSET |
46 | 0000000 | 46 | 0000000 (can also be even more bogus like 17767153361) |
47 | system-image-i686 | 47 | system-image-i686 |
48 | system-image-mips | 48 | system-image-mips - od is buggy |
49 | system-image-mipsel | 49 | system-image-mipsel - od is buggy |
50 | od is buggy on mips[el]: | ||
51 | # echo Hello-hello-hello-hello | od -b | ||
52 | 0000000 110 145 154 154 157 055 150 145 154 154 157 055 150 145 154 154 | ||
53 | 17767153361 157 055 150 145 154 154 157 012 | ||
54 | 0000000 | ||
55 | system-image-x86_64 | 50 | system-image-x86_64 |
51 | system-image-powerpc - qemu 1.2.2 didn't work, 2.4.0 worked; od is buggy | ||
52 | system-image-sparc - qemu 1.2.2 didn't work, 2.4.0 worked; od is buggy | ||
56 | 53 | ||
57 | And these did not: | 54 | And these did not: |
58 | system-image-armv6l - hang on "Uncompressing Linux... done, booting the kernel" | 55 | system-image-armv6l - hang on "Uncompressing Linux... done, booting the kernel" |
59 | system-image-powerpc - hang early in kernel boot | ||
60 | system-image-sparc - hang early in userspace | ||
61 | system-image-m68k - my qemu doesn't like "-M q800" | 56 | system-image-m68k - my qemu doesn't like "-M q800" |
62 | system-image-mips64 - init dies "Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000a" | 57 | system-image-mips64 - init dies "Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000a" |
63 | system-image-sh4 - qemu segfaults early in kernel boot | 58 | system-image-sh4 - qemu segfaults early in kernel boot |