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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 21E2C3894C2D for ; Fri, 13 Nov 2020 19:04:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 21E2C3894C2D Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-493-NdgosFN_PQy7KuYigfg-Xg-1; Fri, 13 Nov 2020 14:04:12 -0500 X-MC-Unique: NdgosFN_PQy7KuYigfg-Xg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 548C96D24E; Fri, 13 Nov 2020 19:04:10 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-176.phx2.redhat.com [10.3.112.176]) by smtp.corp.redhat.com (Postfix) with ESMTP id C968860C07; Fri, 13 Nov 2020 19:04:09 +0000 (UTC) Subject: Re: ubsan: d-demangle.c:214 signed integer overflow To: Alan Modra , Iain Buclaw Cc: Ian Lance Taylor , gcc-patches@gcc.gnu.org References: <20200903130116.GQ15695@bubble.grove.modra.org> <1599163400.8r2ly1k30n.astroid@galago.none> <20200904005939.GR15695@bubble.grove.modra.org> <1599207109.qqwjbgoeso.astroid@galago.none> <20200904133403.GV15695@bubble.grove.modra.org> From: Jeff Law Message-ID: Date: Fri, 13 Nov 2020 12:04:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <20200904133403.GV15695@bubble.grove.modra.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Nov 2020 19:04:15 -0000 On 9/4/20 7:34 AM, Alan Modra via Gcc-patches wrote: > So this one is on top of the previously posted patch. > > * d-demangle.c (string_need): Take a size_t n arg, and use size_t tem. > (string_append): Use size_t n. > (string_appendn, string_prependn): Take a size_t n arg. > (TEMPLATE_LENGTH_UNKNOWN): Define as -1UL. > * d-demangle.c (dlang_number): Make "ret" an unsigned long*. > Only succeed for result of [0,4294967295UL]. > (dlang_decode_backref): Only succeed for result [1,MAX_LONG]. > (dlang_backref): Remove now unnecessary range check. > (dlang_symbol_name_p): Likewise. > (dlang_lname, dlang_parse_template): Take an unsigned long len > arg. > (dlang_symbol_backref, dlang_identifier, dlang_parse_integer), > (dlang_parse_integer, dlang_parse_string), > (dlang_parse_arrayliteral, dlang_parse_assocarray), > (dlang_parse_structlit, dlang_parse_tuple), > (dlang_template_symbol_param, dlang_template_args): Use > unsigned long variables. > * testsuite/d-demangle-expected: Add new tests. Explicitly leaving this to Iain. jeff