From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7814) id 7365C3857C7B; Sat, 28 Aug 2021 00:31:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7365C3857C7B Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Fangrui Song To: glibc-cvs@sourceware.org Subject: [glibc/maskray/grte] iconv: Accept redundant shift sequences in IBM1364 [BZ #26224] X-Act-Checkin: glibc X-Git-Author: Arjun Shankar X-Git-Refname: refs/heads/maskray/grte X-Git-Oldrev: 54178fab54efe4dff53af839c271ba37765c3e74 X-Git-Newrev: 029d238eecac4c03c57081cacf465337366d59e5 Message-Id: <20210828003134.7365C3857C7B@sourceware.org> Date: Sat, 28 Aug 2021 00:31:34 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Aug 2021 00:31:34 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=029d238eecac4c03c57081cacf465337366d59e5 commit 029d238eecac4c03c57081cacf465337366d59e5 Author: Arjun Shankar Date: Wed Nov 4 12:19:38 2020 +0100 iconv: Accept redundant shift sequences in IBM1364 [BZ #26224] The IBM1364, IBM1371, IBM1388, IBM1390 and IBM1399 character sets share converter logic (iconvdata/ibm1364.c) which would reject redundant shift sequences when processing input in these character sets. This led to a hang in the iconv program (CVE-2020-27618). This commit adjusts the converter to ignore redundant shift sequences and adds test cases for iconv_prog hangs that would be triggered upon their rejection. This brings the implementation in line with other converters that also ignore redundant shift sequences (e.g. IBM930 etc., fixed in commit 692de4b3960d). Reviewed-by: Carlos O'Donell Diff: --- iconvdata/ibm1364.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/iconvdata/ibm1364.c b/iconvdata/ibm1364.c index b833273aa8..27900c4307 100644 --- a/iconvdata/ibm1364.c +++ b/iconvdata/ibm1364.c @@ -157,24 +157,14 @@ enum \ if (__builtin_expect (ch, 0) == SO) \ { \ - /* Shift OUT, change to DBCS converter. */ \ - if (curcs == db) \ - { \ - result = __GCONV_ILLEGAL_INPUT; \ - break; \ - } \ + /* Shift OUT, change to DBCS converter (redundant escape okay). */ \ curcs = db; \ ++inptr; \ continue; \ } \ if (__builtin_expect (ch, 0) == SI) \ { \ - /* Shift IN, change to SBCS converter. */ \ - if (curcs == sb) \ - { \ - result = __GCONV_ILLEGAL_INPUT; \ - break; \ - } \ + /* Shift IN, change to SBCS converter (redundant escape okay). */ \ curcs = sb; \ ++inptr; \ continue; \