From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id E92E9385841F for ; Thu, 8 Feb 2024 16:19:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E92E9385841F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E92E9385841F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707409195; cv=none; b=HgyggbS6U5lfdPc7OcOj38Ho04NBK3yDdDUJNDusc3d2I+0r4n0TmjzTHxch1+LDH9pymDY3y5mL92LOZjl7gpiQ4Mxi1rhh6owoTiAAy7rhtYs8w+tyYSB1Sp7ALpEzP83DLFRNfkLzsKkYHW9EEVCJOGLzpke7fYQGa2V7ND0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707409195; c=relaxed/simple; bh=caohloLeZOLAFDwqi3sFDDJM5J/S9HCr+5g7YWW6rWo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=bkbLnvP5TTwa5n8cKr8T5uJXKJDogMNJuHsSP6nxba2mTL5yEqX/RMYNV1i7uEUTLj7KVCbym38kupY8wWzDQF0ypsQ0Y1DU3/71wh7n/yjFqxttklizu7XqozBcfEI+HTmdGvhfYwwGlh9kzrpygDvO6tJXVNU1tmHW0pzddfQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5004a.ext.cloudfilter.net ([10.0.29.221]) by cmsmtp with ESMTPS id Y6nar29YHCF6GY77vr4dEZ; Thu, 08 Feb 2024 16:19:51 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id Y77ur2SLao87WY77vrSsiB; Thu, 08 Feb 2024 16:19:51 +0000 X-Authority-Analysis: v=2.4 cv=LcWf6Sfi c=1 sm=1 tr=0 ts=65c4ff27 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=FuLcyttaAAAA:8 a=517xWuIBvweDCMyS8N8A:9 a=MC5N0o4Zdobc3yPVA2xq:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=XyK5ZyjnIBCKYkBwpieUu95VdloibpfnGxYjKUnM8go=; b=DOyCpW4fPHtbKroJzBV+lekb+U IXLJPXxusu0o1IiGsJ/BKqt1gAMgVyLZaGdXymBDBEjCNGitdDR2usrqDL66y0vn69hOF3XmhhNNR +I+AtL2UkQyzBQiu6Nnek4297; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:45500 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rY77u-001Z2J-1Q; Thu, 08 Feb 2024 09:19:50 -0700 From: Tom Tromey To: Kirill Radkin Cc: , , , , Subject: Re: [PATCH] gdbserver: Fix overflow detection in gdbserver References: <87edfe2qiy.fsf@tromey.com> <20240110145746.57459-1-kirill.radkin@syntacore.com> X-Attribution: Tom Date: Thu, 08 Feb 2024 09:19:49 -0700 In-Reply-To: <20240110145746.57459-1-kirill.radkin@syntacore.com> (Kirill Radkin's message of "Wed, 10 Jan 2024 17:57:46 +0300") Message-ID: <87plx79bdm.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.68.157 X-Source-L: No X-Exim-ID: 1rY77u-001Z2J-1Q X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net (murgatroyd) [97.122.68.157]:45500 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfPT9bOXbf9qgHNow0LlimYBw1ni6BuqKKNpuXTvrqYHdCE/YuiwOdncBw4rz/W5Zba1LTrXYyAAvLJmjunaBTtD6NVz0m4mpVVceR1iUWmSN70Ll6Gc4 8yFcWme0jUdgVt3jQmtOXDSG2rbtYQQCEvQeMTQyp4Z0cRc70nezH/5VHEeAtiS9WvQbT2pAdCXFzcz9PbJQYLANDh8VwU2t044= X-Spam-Status: No, score=-3016.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,JMQ_SPF_NEUTRAL,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>>>> "Kirill" == Kirill Radkin writes: Thank you for the patch. I didn't see a reply to this one. Kirill> +template Kirill> static int Kirill> -require_int (char **pp, int *value) Kirill> +require_int (char **pp, T *value) Kirill> { Kirill> + constexpr bool is_signed = std::is_signed::value; Kirill> + if (!is_signed) Kirill> + return -1; I don't understand this early return. If using an unsigned type here is intended to be invalid, then I think that should be enforced at compile time. Kirill> - if (count >= 8 || (count == 7 && firstdigit >= 0x8)) Kirill> + if (count >= max_count || (count == (max_count - 1) Kirill> + && firstdigit >= 0x8)) Kirill> return -1; However, it seems pretty simple to handle unsigned here as well. thanks, Tom