aboutsummaryrefslogtreecommitdiff
path: root/coreutils/uudecode.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-07-14 17:24:59 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-14 17:24:59 +0200
commit7b6e8f3f1a8ea1ccf09b3dc20b6387eec9cdc55d (patch)
treeab630f041ddc9803f6445583a101597ff91519f1 /coreutils/uudecode.c
parent90678f0cd72e39806b159a551af85265608219b6 (diff)
downloadbusybox-7b6e8f3f1a8ea1ccf09b3dc20b6387eec9cdc55d.tar.gz
uuencode: allow space instead of "`" as padding char. Closes 10046
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/uudecode.c')
-rw-r--r--coreutils/uudecode.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/coreutils/uudecode.c b/coreutils/uudecode.c
index ddce2548b..2fe771f69 100644
--- a/coreutils/uudecode.c
+++ b/coreutils/uudecode.c
@@ -47,10 +47,16 @@ static void FAST_FUNC read_stduu(FILE *src_stream, FILE *dst_stream, int flags U
line = xmalloc_fgets_str_len(src_stream, "\n", &line_len);
if (!line)
break;
- /* Handle both Unix and MSDOS text, and stray trailing spaces */
+ /* Handle both Unix and MSDOS text.
+ * Note: space should not be trimmed, some encoders use it instead of "`"
+ * for padding of last incomplete 4-char block.
+ */
str_len = line_len;
- while (--str_len >= 0 && isspace(line[str_len]))
+ while (--str_len >= 0
+ && (line[str_len] == '\n' || line[str_len] == '\r')
+ ) {
line[str_len] = '\0';
+ }
if (strcmp(line, "end") == 0) {
return; /* the only non-error exit */
@@ -65,7 +71,7 @@ static void FAST_FUNC read_stduu(FILE *src_stream, FILE *dst_stream, int flags U
encoded_len = line[0] * 4 / 3;
/* Check that line is not too short. (we tolerate
- * overly _long_ line to accommodate possible extra '`').
+ * overly _long_ line to accommodate possible extra "`").
* Empty line case is also caught here. */
if (str_len <= encoded_len) {
break; /* go to bb_error_msg_and_die("short file"); */