From patchwork Wed Aug 19 23:07:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Gautier X-Patchwork-Id: 40309 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ABAA2386188D; Wed, 19 Aug 2020 23:05:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ABAA2386188D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1597878358; bh=2v1mjI0h8ntdHJIF9mt1a1BNSxz01Zrvt6SeVsDMxC4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=jZUsOiHxwN1pp8ITYnq4CMNQnkdzMii3kN2P/DieYFh+UHuIhUDz7idgpmWFdPAxD eBXWmvnGFmwnDlSN3IEoA+65kVi9CqmMr1gLmrF6PdWHieZNx8+Dts0NI1hv9/WqOY WfJ8mfehMfxlnKx6VNlGYd+YjDc6ER6uZbQnTadI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org 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) To: libc-alpha@sourceware.org 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 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-Patchwork-Original-From: Max Gautier via Libc-alpha From: Max Gautier Reply-To: Max Gautier Cc: Max Gautier Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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; \ } \