diff options
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/uudecode.c | 12 |
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 | |||
| 47 | line = xmalloc_fgets_str_len(src_stream, "\n", &line_len); | 47 | line = xmalloc_fgets_str_len(src_stream, "\n", &line_len); |
| 48 | if (!line) | 48 | if (!line) |
| 49 | break; | 49 | break; |
| 50 | /* Handle both Unix and MSDOS text, and stray trailing spaces */ | 50 | /* Handle both Unix and MSDOS text. |
| 51 | * Note: space should not be trimmed, some encoders use it instead of "`" | ||
| 52 | * for padding of last incomplete 4-char block. | ||
| 53 | */ | ||
| 51 | str_len = line_len; | 54 | str_len = line_len; |
| 52 | while (--str_len >= 0 && isspace(line[str_len])) | 55 | while (--str_len >= 0 |
| 56 | && (line[str_len] == '\n' || line[str_len] == '\r') | ||
| 57 | ) { | ||
| 53 | line[str_len] = '\0'; | 58 | line[str_len] = '\0'; |
| 59 | } | ||
| 54 | 60 | ||
| 55 | if (strcmp(line, "end") == 0) { | 61 | if (strcmp(line, "end") == 0) { |
| 56 | return; /* the only non-error exit */ | 62 | 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 | |||
| 65 | 71 | ||
| 66 | encoded_len = line[0] * 4 / 3; | 72 | encoded_len = line[0] * 4 / 3; |
| 67 | /* Check that line is not too short. (we tolerate | 73 | /* Check that line is not too short. (we tolerate |
| 68 | * overly _long_ line to accommodate possible extra '`'). | 74 | * overly _long_ line to accommodate possible extra "`"). |
| 69 | * Empty line case is also caught here. */ | 75 | * Empty line case is also caught here. */ |
| 70 | if (str_len <= encoded_len) { | 76 | if (str_len <= encoded_len) { |
| 71 | break; /* go to bb_error_msg_and_die("short file"); */ | 77 | break; /* go to bb_error_msg_and_die("short file"); */ |
