From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BEA5D3858C53 for ; Mon, 7 Nov 2022 23:04:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BEA5D3858C53 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667862280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Af+6ypb0wTFYp3EKfKgTFYNp0mwWkxd1vKoNzfVgrVo=; b=fbJJPDdMseYcd0oATpJ9n4RfQ8U8cesv02+RBwj2D1J8W3s66Q/hHZyMK8e/c7HgUcgTGj 1LrjsEimV7TVP4yPPHoLzhqGr7dpL3RKAr8T8sM9SiXDb6bsVDe2lOC3xJNDwUV2bjwAUc r1bVphN/PtymC8Z1Q2/g0MHTTV6ZXfQ= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-517-ZsIwrBuBPoytepPzPOd1-g-1; Mon, 07 Nov 2022 18:04:39 -0500 X-MC-Unique: ZsIwrBuBPoytepPzPOd1-g-1 Received: by mail-qk1-f200.google.com with SMTP id i17-20020a05620a249100b006fa2e10a2ecso11397475qkn.16 for ; Mon, 07 Nov 2022 15:04:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Af+6ypb0wTFYp3EKfKgTFYNp0mwWkxd1vKoNzfVgrVo=; b=eLZlQaODVHNVtCAJ+Y8NGD8a7WvspqDwfKe50cuHCvOWBElaB25MpV1MwoyWKlTuqJ h2t9T/5QUtMx74BF5yi+JtGEEeQkAJPK9HOv7FeVEAB0OJ7zmdaeAsnijQ12ROjp/kdM QQRL0yyW6pRYXL0WmsNTLUC2ztm5pQ4wOVYgb8tMIJ0hlsE7hmxJENAZ+Cttj4bUR9gv fPjNDnRR8RdHn/rBjW9cjMPOQzuBFNYQ7RrrAHqp9U9Sp5dhSRKnn4qvdP24EK5TfDI1 c4MIp/m0RFyceEjrgVeJJF5B5JVkFhq2pnQHETvAIhMKv+mdjwjU+EExAPMg0ZSAuYs8 8BeA== X-Gm-Message-State: ACrzQf3ApiBoSvf/ECpbBR0LKGlQ3OPLjdpWRFo7ckJFqyzbGSrPJ18p TWdvt30gEWPFmf4FGgcZZUtKw3BYfKIBhrDW+zxdGisxTqlCSXx/1J5SKb2I8bqxm5/CJYHM3xl jrdiJBSA= X-Received: by 2002:a37:c205:0:b0:6fa:18aa:c514 with SMTP id i5-20020a37c205000000b006fa18aac514mr35286285qkm.549.1667862278843; Mon, 07 Nov 2022 15:04:38 -0800 (PST) X-Google-Smtp-Source: AMsMyM4fwsl6YUor0O+TbEggerMNwGa9UWtuTTmtBkxCLZWuYyfB1fAXcZltxaDUrxnNSe4ppHEd2w== X-Received: by 2002:a37:c205:0:b0:6fa:18aa:c514 with SMTP id i5-20020a37c205000000b006fa18aac514mr35286266qkm.549.1667862278572; Mon, 07 Nov 2022 15:04:38 -0800 (PST) Received: from [172.22.36.61] (rrcs-24-43-233-8.west.biz.rr.com. [24.43.233.8]) by smtp.gmail.com with ESMTPSA id bp32-20020a05620a45a000b006faa88ba2b5sm7753656qkb.7.2022.11.07.15.04.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 07 Nov 2022 15:04:38 -0800 (PST) Message-ID: <3c8ab0d6-d17e-1933-8d35-b0c0209d06a8@redhat.com> Date: Mon, 7 Nov 2022 13:04:35 -1000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v2 1/3] libcpp: reject codepoints above 0x10FFFF To: Ben Boeckel , gcc-patches@gcc.gnu.org Cc: nathan@acm.org, fortran@gcc.gnu.org, gcc@gcc.gnu.org, brad.king@kitware.com, dmalcolm@redhat.com, mliska@suse.cz, anlauf@gmx.de References: <20221027231645.67623-1-ben.boeckel@kitware.com> <20221027231645.67623-2-ben.boeckel@kitware.com> From: Jason Merrill In-Reply-To: <20221027231645.67623-2-ben.boeckel@kitware.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 10/27/22 13:16, Ben Boeckel wrote: > Unicode does not support such values because they are unrepresentable in > UTF-16. > > Signed-off-by: Ben Boeckel > --- > libcpp/ChangeLog | 6 ++++++ > libcpp/charset.cc | 4 ++-- > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog > index 18d5bcceaf0..4d707277531 100644 > --- a/libcpp/ChangeLog > +++ b/libcpp/ChangeLog > @@ -1,3 +1,9 @@ > +2022-10-27 Ben Boeckel > + > + * include/charset.cc: Reject encodings of codepoints above 0x10FFFF. > + UTF-16 does not support such codepoints and therefore all Unicode > + rejects such values. > + > 2022-10-19 Lewis Hyatt > > * include/cpplib.h (struct cpp_string): Use new "string_length" GTY. > diff --git a/libcpp/charset.cc b/libcpp/charset.cc > index 12a398e7527..e9da6674b5f 100644 > --- a/libcpp/charset.cc > +++ b/libcpp/charset.cc > @@ -216,7 +216,7 @@ one_utf8_to_cppchar (const uchar **inbufp, size_t *inbytesleftp, > if (c <= 0x3FFFFFF && nbytes > 5) return EILSEQ; > > /* Make sure the character is valid. */ > - if (c > 0x7FFFFFFF || (c >= 0xD800 && c <= 0xDFFF)) return EILSEQ; > + if (c > 0x10FFFF || (c >= 0xD800 && c <= 0xDFFF)) return EILSEQ; Please also adjust the comment before the function that talks about the 0x7FFFFFFF maximum. > > *cp = c; > *inbufp = inbuf; > @@ -320,7 +320,7 @@ one_utf32_to_utf8 (iconv_t bigend, const uchar **inbufp, size_t *inbytesleftp, > s += inbuf[bigend ? 2 : 1] << 8; > s += inbuf[bigend ? 3 : 0]; > > - if (s >= 0x7FFFFFFF || (s >= 0xD800 && s <= 0xDFFF)) > + if (s > 0x10FFFF || (s >= 0xD800 && s <= 0xDFFF)) > return EILSEQ; > > rval = one_cppchar_to_utf8 (s, outbufp, outbytesleftp);