From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C5AF03858D1E; Tue, 18 Apr 2023 17:44:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C5AF03858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681839865; bh=Hp6YyBYApdQgwoDJUlI9s4ooxVc0ikSrfo8Xf0sxlls=; h=From:To:Subject:Date:From; b=y40AXA7AhzaFB4GPJdTgnioPp8qNe4LvVpnafyuWKMzKAbP/XPMO1gcMqX6QbaB/J BwGoL1JxwA77zyx2O0eGf+s2zv3bAs1AaOdpPoBxT8JRWo6CSzxrYwSDuUJpIQK+8F N33yjN70qqJywQ7flTbgBW2Z9LK31za8h/9uSP9Q= From: "bruno at clisp dot org" To: glibc-bugs@sourceware.org Subject: [Bug libc/30371] New: C2x strtol binary constant handling is incomplete Date: Tue, 18 Apr 2023 17:44:24 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: libc X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bruno at clisp dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D30371 Bug ID: 30371 Summary: C2x strtol binary constant handling is incomplete Product: glibc Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: bruno at clisp dot org CC: drepper.fsp at gmail dot com Target Milestone: --- Created attachment 14838 --> https://sourceware.org/bugzilla/attachment.cgi?id=3D14838&action=3Ded= it proposed fix In the functions strtol/strtoul/strtoll/strtoull, support for binary constants (such as 0b100111), as specified in ISO C 2x, was added in glibc commit 64924422a99690d147a166b4de3103f3bf3eaf6c, on 2023-02-17. But it is incomplete: The special input string "0b" with no binary digits is not handled. Here's a test case: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D tst-strtol-bin= ary-no-digits.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D #include #include #include int main () { { const char input[] =3D "0b"; char *ptr; long result; errno =3D 0; result =3D strtol (input, &ptr, 2); assert (result =3D=3D 0L); assert (ptr =3D=3D input + 1); assert (errno =3D=3D 0); } { const char input[] =3D "0b"; char *ptr; long result; errno =3D 0; result =3D strtol (input, &ptr, 0); assert (result =3D=3D 0L); assert (ptr =3D=3D input + 1); assert (errno =3D=3D 0); } } =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Find attached a correction for this. I have tested it in Gnulib (which has very similar source code as glibc for this functionality), not in Glibc directly. I previously reported this to libc-alpha at https://sourceware.org/pipermail/libc-alpha/2023-March/146367.html but I now realize that this was not the proper reporting channel. Sorry about that. --=20 You are receiving this mail because: You are on the CC list for the bug.=