From d5d534301be376ccdd64cc02c41f16d3b77c16e4 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Wed, 17 Jan 2018 13:13:12 +0000 Subject: [PATCH] base64.c: fix handling of EOF and LF (fixes Debian bug #271939) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit LF can occur before the end of a full line (76 characters) if it’s immediately followed by EOF. The last line can be any number of quadruplets long; it need not be 76 characters. (I suspect this was an attempt to deal with LF without the extra call to get_byte and goto.) --- src/base64.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/base64.c b/src/base64.c index 7afd8be..e353994 100644 --- a/src/base64.c +++ b/src/base64.c @@ -149,19 +149,20 @@ transform_base64_data (RECODE_SUBTASK subtask) /* Accept wrapping lines, reversibly if at each 76 characters. */ character = get_byte (subtask); + + top: if (character == EOF) - { - if (counter != 0) - RETURN_IF_NOGO (RECODE_NOT_CANONICAL, subtask); - SUBTASK_RETURN (subtask); - } + SUBTASK_RETURN (subtask); if (character == '\n') { + character = get_byte (subtask); + if (character == EOF) + SUBTASK_RETURN (subtask); if (counter != MIME_LINE_LENGTH / 4) RETURN_IF_NOGO (RECODE_NOT_CANONICAL, subtask); counter = 0; - continue; + goto top; } if (character == '\r') -- 2.40.0