[PATCH v3 4/5] Make terminating base64 sequences mandatory
Max Gautier
mg@max.gautier.name
Mon Jan 25 09:02:25 GMT 2021
In the modified UTF-7 encoding, unlike in UTF-7, one MUST terminate all
base64 sequence with the '-' character.
MODIFIED-UTF-7 -> INTERNAL : make unterminated sequences illegal
INTERNAL -> MODIFIED-UTF-7 : always terminate the sequences
---
iconvdata/imap-utf-7.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/iconvdata/imap-utf-7.c b/iconvdata/imap-utf-7.c
index ebd66d3388..45629a48f8 100644
--- a/iconvdata/imap-utf-7.c
+++ b/iconvdata/imap-utf-7.c
@@ -176,7 +176,7 @@ base64 (unsigned int i)
i = 62; \
else if (ch == ',') \
i = 63; \
- else \
+ else if (ch == '-') \
{ \
/* Terminate base64 encoding. */ \
\
@@ -188,12 +188,14 @@ base64 (unsigned int i)
STANDARD_FROM_LOOP_ERR_HANDLER ((statep->__count = 0, 1)); \
} \
\
- if (ch == '-') \
- inptr++; \
+ inptr++; \
\
statep->__count = 0; \
continue; \
} \
+ else \
+ STANDARD_FROM_LOOP_ERR_HANDLER ((statep->__count = 0, 1)); \
+ /* Terminating '-' is required */ \
\
/* Concatenate the base64 integer i to the accumulator. */ \
shift = (statep->__count >> 3); \
@@ -354,8 +356,7 @@ base64 (unsigned int i)
\
if ((statep->__count & 0x18) >= 0x10) \
*outptr++ = base64 ((statep->__count >> 3) & ~3); \
- if (ismbase64 (ch)) \
- *outptr++ = '-'; \
+ *outptr++ = '-'; \
*outptr++ = (unsigned char) ch; \
statep->__count = 0; \
} \
--
2.30.0
More information about the Libc-alpha
mailing list