| Message ID | 217297ed-d56d-45c4-a1ec-d0e4f758cfdc@posteo.de |
|---|---|
| State | New |
| Headers |
Return-Path: <newlib-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id DFBFB4BA23E0 for <patchwork@sourceware.org>; Thu, 12 Feb 2026 16:56:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFBFB4BA23E0 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=posteo.de header.i=@posteo.de header.a=rsa-sha256 header.s=2017 header.b=UdEbwcil X-Original-To: newlib@sourceware.org Delivered-To: newlib@sourceware.org Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by sourceware.org (Postfix) with ESMTPS id E42764BA2E15 for <newlib@sourceware.org>; Thu, 12 Feb 2026 16:56:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E42764BA2E15 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=posteo.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=posteo.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E42764BA2E15 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.67.36.66 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770915361; cv=none; b=bNfqEYSiXtE+hDBGM/Ozzf887lZsUTXC2cOeioKyYgQxHh9FcY49vYM8ZLOkwEiYoPIB+UGW4jX5GHHpFXvwXLsKGNvJcTBLQQcwvIlNx4SAEe5EfwOPK60NI2v7rf+fkbm32+/4F5o8nLjHKBQaI4fQ/VCYDRvRm2ApzPxzQR8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770915361; c=relaxed/simple; bh=sCK8v+LGJ1H2FMVs+cAEM/64XRVYwEx56SnKC1WCAYo=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=UrhIeEv/brFTpyHu0abZ1RSWXeYULWX7y3OTwZvtu7peQr5mXYo9txjsckbwsaWrmrmKZg8KYulaRY9W123HvmkLLCIRb0F30p8C2BSl6Q1smbqP+tH+2qjPUaCldXqhPICtdOoZwYUtvmGRcPcHIO1JBLs7UPxbEZoMfuaBVRM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E42764BA2E15 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id C060A240101 for <newlib@sourceware.org>; Thu, 12 Feb 2026 17:55:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=posteo.de; s=2017; t=1770915354; bh=u+z3Av/UgeAn2xqp50hZRJNVLZnVBPPjO5VxgdNlMl0=; h=Content-Type:Message-ID:Date:MIME-Version:To:From:Subject:From; b=UdEbwcilot5LqGwTbBik/no8vkqgXvEPM9RDel2REwG3nYJq133u7RgyrDTXx0yog wUVFrSVnMzSC7sqOKI9nfpS4kgVpld5kaCpabOH/5BcM0Cp9KS8wcBPuF6YSek+vBo 8/oQU80sknrZNObUFpNd9vKH9DSttgpupTHv6Riszfiz37V7pMyWQaUgvOKAFlNt/P uOv5rCgm644tc3JV/zkgnoYnr04tSESP6scuqxOwtMJsoEHIMYGnM7NbXnDjT5dzTt tED3z400WsePAS/OPyH3ryX0Zbu6xOPIjoWoCKVeYaR29ZvTPk/HgR7J2SmatjjKLC OJagQY9n9NH8g== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4fBhJP1KwQz6trs for <newlib@sourceware.org>; Thu, 12 Feb 2026 17:55:48 +0100 (CET) Content-Type: multipart/alternative; boundary="------------FYKJru4OqYPnZ0hMpn12zh6D" Message-ID: <217297ed-d56d-45c4-a1ec-d0e4f758cfdc@posteo.de> Date: Thu, 12 Feb 2026 16:55:49 +0000 MIME-Version: 1.0 To: newlib@sourceware.org Content-Language: en-US, de-DE From: Johannes Hack <johannes.hack@posteo.de> Subject: undefined behavior itoa X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H2, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Newlib mailing list <newlib.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/newlib>, <mailto:newlib-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/newlib/> List-Post: <mailto:newlib@sourceware.org> List-Help: <mailto:newlib-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/newlib>, <mailto:newlib-request@sourceware.org?subject=subscribe> Errors-To: newlib-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
undefined behavior itoa
|
|
Commit Message
Johannes Hack
Feb. 12, 2026, 4:55 p.m. UTC
Hello, I believe I have found undefined behavior in |newlib/libc/stdlib/itoa.c| when handling |INT_MIN.| Best regards Johannes ``` ```
Comments
Hi Johannes, thanks, but your patch doesn't apply cleanly. Can you please send this as a git patch created with git format-patch, and if your mailer breks whitespaces (as it appears to), please send the patch as plain-text attachment (you may want to drop html entirely). Thanks, Corinna On Feb 12 16:55, Johannes Hack wrote: > Hello, > I believe I have found undefined behavior in |newlib/libc/stdlib/itoa.c| > when handling |INT_MIN.| > Best regards > Johannes > ``` > diff --git a/newlib/libc/stdlib/itoa.c b/newlib/libc/stdlib/itoa.c > index 7a7daf0ce..9271ec443 100644 > --- a/newlib/libc/stdlib/itoa.c > +++ b/newlib/libc/stdlib/itoa.c > @@ -49,7 +49,7 @@ __itoa (int value, > if ((base == 10) && (value < 0)) > { > str[i++] = '-'; > - uvalue = (unsigned)-value; > + uvalue = -(unsigned)value; > } > else > uvalue = (unsigned)value; > ```
diff --git a/newlib/libc/stdlib/itoa.c b/newlib/libc/stdlib/itoa.c index 7a7daf0ce..9271ec443 100644 --- a/newlib/libc/stdlib/itoa.c +++ b/newlib/libc/stdlib/itoa.c @@ -49,7 +49,7 @@ __itoa (int value, if ((base == 10) && (value < 0)) { str[i++] = '-'; - uvalue = (unsigned)-value; + uvalue = -(unsigned)value; } else uvalue = (unsigned)value;