From patchwork Mon Jan 25 09:02:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Gautier X-Patchwork-Id: 41804 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 8DE183945C0B; Mon, 25 Jan 2021 09:03:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8DE183945C0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611565385; bh=A9sIqJ5IPCZXqH5nSsFNggWQMoZO4ytUwm7WF5y2cLY=; 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=CZW75vZ6vR/0mac6CkW/foGJmfK6iBJhs2PRUY0OLkxy62HcX7/g4t6ZBrQI3Dkc5 6uY9jZaRlk1wuF33XmqS/nYGkzYZ+XsgiPKTLS9GBhgIWw8IttkrLz2ERkY95wMLDA zmxkVBe2HG7sIerjgKm14v6e38fh4A9YKFm1L9CU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by sourceware.org (Postfix) with ESMTPS id 6BD3439450FD for ; Mon, 25 Jan 2021 09:03:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6BD3439450FD Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4DPP5w357GzQlYY; Mon, 25 Jan 2021 10:03:00 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter06.heinlein-hosting.de (spamfilter06.heinlein-hosting.de [80.241.56.125]) (amavisd-new, port 10030) with ESMTP id LTDPcmsR9ANv; Mon, 25 Jan 2021 10:02:57 +0100 (CET) To: libc-alpha@sourceware.org Subject: [PATCH v3 4/5] Make terminating base64 sequences mandatory Date: Mon, 25 Jan 2021 10:02:25 +0100 Message-Id: <20210125090226.39967-5-mg@max.gautier.name> In-Reply-To: <20210125090226.39967-1-mg@max.gautier.name> References: <87y2m9agmm.fsf@mid.deneb.enyo.de> <20210125090226.39967-1-mg@max.gautier.name> MIME-Version: 1.0 X-MBO-SPAM-Probability: X-Rspamd-Score: -4.11 / 15.00 / 15.00 X-Rspamd-Queue-Id: 7036A17D7 X-Rspamd-UID: f378e0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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/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; \ } \