From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout-y-111.mailbox.org (mout-y-111.mailbox.org [IPv6:2001:67c:2050:1::465:111]) by sourceware.org (Postfix) with ESMTPS id 45DF43861847 for ; Wed, 19 Aug 2020 23:05:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 45DF43861847 Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mout-y-111.mailbox.org (Postfix) with ESMTPS id 4BX3Kv2F7NzQlPs; Thu, 20 Aug 2020 01:05:55 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id ZqXt_eNNrwsR; Thu, 20 Aug 2020 01:05:52 +0200 (CEST) From: Max Gautier To: libc-alpha@sourceware.org Cc: Max Gautier Subject: [PATCH 4/5] Make terminating base64 sequences mandatory Date: Thu, 20 Aug 2020 01:07:01 +0200 Message-Id: <20200819230702.229822-5-mg@max.gautier.name> In-Reply-To: <20200819230702.229822-1-mg@max.gautier.name> References: <20200819230702.229822-1-mg@max.gautier.name> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-MBO-SPAM-Probability: X-Rspamd-Score: -4.44 / 15.00 / 15.00 X-Rspamd-Queue-Id: 72A40178C X-Rspamd-UID: b0c8f6 X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Aug 2020 23:05:57 -0000 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/modified-utf-7.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/iconvdata/modified-utf-7.c b/iconvdata/modified-utf-7.c index e6eb784891..27cc4a88c3 100644 --- a/iconvdata/modified-utf-7.c +++ b/iconvdata/modified-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.28.0