From unknown Sun Jun 22 08:11:13 2025 X-Loop: help-debbugs@gnu.org Subject: bug#57211: 29.0.50; generate-new-buffer-name sprintf format overflow warning Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: eggert@cs.ucla.edu, bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Aug 2022 16:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 57211 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 57211@debbugs.gnu.org Cc: Paul Eggert X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: Paul Eggert Received: via spool by submit@debbugs.gnu.org id=B.166049581324069 (code B ref -1); Sun, 14 Aug 2022 16:51:02 +0000 Received: (at submit) by debbugs.gnu.org; 14 Aug 2022 16:50:13 +0000 Received: from localhost ([127.0.0.1]:39748 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNGoW-0006G9-UF for submit@debbugs.gnu.org; Sun, 14 Aug 2022 12:50:13 -0400 Received: from lists.gnu.org ([209.51.188.17]:56670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNGoU-0006Fy-Cp for submit@debbugs.gnu.org; Sun, 14 Aug 2022 12:50:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNGoU-0005tn-7g for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2022 12:50:10 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:46759) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oNGoR-0006aJ-PO for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2022 12:50:09 -0400 Received: by mail-wr1-x434.google.com with SMTP id l4so6594682wrm.13 for ; Sun, 14 Aug 2022 09:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=content-transfer-encoding:mime-version:user-agent:message-id:date :subject:to:from:from:to:cc; bh=+QzLztkG+EeGaBUNXIeYd51HncWIoJ7pjOOnTwOV1zo=; b=BA/Xqwn9mgCBIfp+xk1pwYS7rpzTQ5u6dzO9rA/K7o5Nf2s1P+66CtcToLs2Z5klmu 9Pgl24Z23S1+iYKMdvruO6ptqAt7baqZz/+A0ulxwYRDxeEjc2YOnSempVyq2is2dZre mxLR88Z7gdk+ag07Udf0MFe9+19Cw9nju3yvFEycUpy1UcmCXI3ox0chinhOf55XU2j9 C9s4K/uBby0e10SxU4Y3Qc31zWoOXNXZwLmHhMhwlNyaWnoAYle5eu8uNM2jwO8nfCQL U74SdeXfydrJQ5he66gJ64rcc6HeZ+5IhgOccX8vdL/EyR6cwWsgJb/8PA23CMoZ2J8T MXFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :subject:to:from:x-gm-message-state:from:to:cc; bh=+QzLztkG+EeGaBUNXIeYd51HncWIoJ7pjOOnTwOV1zo=; b=gtluEC4ZJNHui8x1Og+k0WYQANuUrTwWEh/PrimVphSr5vB5gb35eZZ7iTlHlEo3bH o2o8jjNYXs3QnayJMTJEDrHiMwlTGh3IT55123L5SGPhP6sKOfjHABx4yyRQ5rJzrMeN 0SfkKj6Y5BWZuSPzOLVEokUP4vHCWyXVhM70c908d5tmqVMICcOkquf8v00t2tA5qk6L NNgXgtG0r+pJHE5grzWDsxcaIEm7nBj4ChSLK32RRprWjoiDumu+OcSMdd26mTbDNR8G 37iyApMV3wkxa5H98ffbdodtJkx0N6yi/UXSVvffz0tF29GcDog3RXKX5DuxGGJ11IqM gTIg== X-Gm-Message-State: ACgBeo18hOnmu5zbwzn0dhuM0QSEnw9R6b8di0fScbYm5lK80dhUQhjx kdrxFyaBU6PXJgkqTmFDbWP4fGNMW4hyTw== X-Google-Smtp-Source: AA6agR7G/NfXuoMBV//wa2ldc3xILtwvU4Cv3Ir0+vRCXRvCNbJpbKgQBAXPaFcBe1/b+p2naE6O1A== X-Received: by 2002:a05:6000:1682:b0:221:599b:a41e with SMTP id y2-20020a056000168200b00221599ba41emr6571639wrd.522.1660495805311; Sun, 14 Aug 2022 09:50:05 -0700 (PDT) Received: from localhost ([2a02:587:322a:4bea:c3bc:c7ac:e79d:a903]) by smtp.gmail.com with ESMTPSA id v16-20020adfedd0000000b002217aed23b4sm4941911wro.12.2022.08.14.09.50.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Aug 2022 09:50:04 -0700 (PDT) From: "Basil L. Contovounesios" Date: Sun, 14 Aug 2022 19:50:03 +0300 Message-ID: <87ilmulqh0.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=contovob@tcd.ie; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) Severity: minor Compiling with gcc (Debian 12.1.0-7) 12.1.0 and -Og, I get the following -Wformat-overflow warning: In file included from buffer.c:33: buffer.c: In function =E2=80=98Fgenerate_new_buffer_name=E2=80=99: buffer.c:1167:46: warning: =E2=80=98sprintf=E2=80=99 may write a terminatin= g nul past the end of the destination [-Wformat-overflow=3D] 1167 | AUTO_STRING_WITH_LEN (lnumber, number, sprintf (number, "-%d"= , i)); | ^~~~~~~~~~~~~~~~~~~~~~= ~~~~ lisp.h:5493:36: note: in definition of macro =E2=80=98AUTO_STRING_WITH_LEN= =E2=80=99 5493 | ((&(struct Lisp_String) {{{len, -1, 0, (unsigned char *) (s= tr)}}}), \ | ^~~ buffer.c:1167:46: note: =E2=80=98sprintf=E2=80=99 output between 3 and 9 by= tes into a destination of size 8 1167 | AUTO_STRING_WITH_LEN (lnumber, number, sprintf (number, "-%d"= , i)); | ^~~~~~~~~~~~~~~~~~~~~~= ~~~~ lisp.h:5493:36: note: in definition of macro =E2=80=98AUTO_STRING_WITH_LEN= =E2=80=99 5493 | ((&(struct Lisp_String) {{{len, -1, 0, (unsigned char *) (s= tr)}}}), \ | ^~~ Can the upper bound 9 ever be achieved? If so, how? If not, is this a GCC bug? Either way, is there a way to pacify the warning? I tried snprintf (number, sizeof number, ...) but got the same warning. BTW, in the preceding int i =3D r % 1000000; can the result of % ever exceed INT_MAX? And do we care either way? Thanks, --=20 Basil In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo versio= n 1.16.0, Xaw3d scroll bars) of 2022-08-14 built on tia Repository revision: 1d3fe256907d5e78a4acedd194e55db8ab952952 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Debian GNU/Linux bookworm/sid Configured using: 'configure CC=3Dgcc-12 'CFLAGS=3D-Og -ggdb3' --config-cache --prefix=3D/home/blc/.local --enable-checking=3Dstructs --with-file-notification=3Dyes --with-x-toolkit=3Dlucid --with-x' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XAW3D XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LANG: en_IE.UTF-8 value of $XMODIFIERS: @im=3Dibus locale-coding-system: utf-8-unix From unknown Sun Jun 22 08:11:13 2025 X-Loop: help-debbugs@gnu.org Subject: bug#57211: 29.0.50; generate-new-buffer-name sprintf format overflow warning Resent-From: Matt Armstrong Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Aug 2022 19:01:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57211 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: "Basil L. Contovounesios" , 57211@debbugs.gnu.org Cc: Paul Eggert Received: via spool by 57211-submit@debbugs.gnu.org id=B57211.16605036124299 (code B ref 57211); Sun, 14 Aug 2022 19:01:02 +0000 Received: (at 57211) by debbugs.gnu.org; 14 Aug 2022 19:00:12 +0000 Received: from localhost ([127.0.0.1]:39939 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNIqK-00017G-Fd for submit@debbugs.gnu.org; Sun, 14 Aug 2022 15:00:12 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:56311) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNIqE-000154-Pj for 57211@debbugs.gnu.org; Sun, 14 Aug 2022 15:00:10 -0400 Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id EB229C0002; Sun, 14 Aug 2022 18:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1660503600; 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=XRvJcxZ2Rlh4YtcWqsXg99hXgJlDP62k2cktQSmDuWI=; b=Ftmauy4TN3esAvhk+aXM5Wr+M1I1YjRQs/zoya1PYeio14VxQclSBiEjvOCP5YVnHGnAlE VnzXVAnOkMEF0aVUiwhZXH2TEBkNQ54wdilgkHpD4927G5uWNmrGIfFzWJ7Nthp/XkjrEz TrvqwnA+QHOeQw4uEJXv7odxzmB/5bN8m0O4PAeUFEM1llI9VDyuv9qkHaoMo4myomXd2R Lkq1wrgOGTCe45jo8d5/K/HV13Qe/1+vJSzNN98kYAVM3JbwLiPJFDk0w0iV8yCu9pLqmm xA6BXakUQZUZWDl07p9TND5Qfsa7MXcM+1y8AMvgFPThxzBUxj5AmfiWTpeSxA== Received: from matt by naz with local (Exim 4.96) (envelope-from ) id 1oNIq2-000KgE-1A; Sun, 14 Aug 2022 11:59:54 -0700 From: Matt Armstrong In-Reply-To: <87ilmulqh0.fsf@tcd.ie> References: <87ilmulqh0.fsf@tcd.ie> Date: Sun, 14 Aug 2022 11:59:54 -0700 Message-ID: <87fshyd51x.fsf@rfc20.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) "Basil L. Contovounesios" via "Bug reports for GNU Emacs, the Swiss army knife of text editors" writes: > Severity: minor > > Compiling with gcc (Debian 12.1.0-7) 12.1.0 and -Og, I get the following > -Wformat-overflow warning: > > In file included from buffer.c:33: > buffer.c: In function =E2=80=98Fgenerate_new_buffer_name=E2=80=99: > buffer.c:1167:46: warning: =E2=80=98sprintf=E2=80=99 may write a terminat= ing nul past the end of the destination [-Wformat-overflow=3D] > 1167 | AUTO_STRING_WITH_LEN (lnumber, number, sprintf (number, "-%= d", i)); > | ^~~~~~~~~~~~~~~~~~~~= ~~~~~~ > lisp.h:5493:36: note: in definition of macro =E2=80=98AUTO_STRING_WITH_LE= N=E2=80=99 > 5493 | ((&(struct Lisp_String) {{{len, -1, 0, (unsigned char *) = (str)}}}), \ > | ^~~ > buffer.c:1167:46: note: =E2=80=98sprintf=E2=80=99 output between 3 and 9 = bytes into a destination of size 8 > 1167 | AUTO_STRING_WITH_LEN (lnumber, number, sprintf (number, "-%= d", i)); > | ^~~~~~~~~~~~~~~~~~~~= ~~~~~~ > lisp.h:5493:36: note: in definition of macro =E2=80=98AUTO_STRING_WITH_LE= N=E2=80=99 > 5493 | ((&(struct Lisp_String) {{{len, -1, 0, (unsigned char *) = (str)}}}), \ > | ^~~ > > Can the upper bound 9 ever be achieved? If so, how? If not, is this a > GCC bug? Either way, is there a way to pacify the warning? > > I tried > > snprintf (number, sizeof number, ...) > > but got the same warning. > > BTW, in the preceding > > int i =3D r % 1000000; > > can the result of % ever exceed INT_MAX? And do we care either way? I assume that gcc is concerned about the possibility that i may be -999999 and the resulting string "--999999" which would overflow the buffer. Gcc doesn't know that get_random() returns only non-negative numbers, and the eassume() call doesn't seem to be enough to convince gcc this fact, or gcc does not infer i is also non-negative. Personally, I'd change this code to use a buffer INT_BUFSIZE_BOUND(int) + sizeof "-" bytes large, like the just code below it. In other words, make it large enough for type of i, and avoid delicate inferences made about the range of values stored in i. The "wasted" bytes in the buffer are minor in comparison to the human effort required to verify this code for security correctness. :-) From unknown Sun Jun 22 08:11:13 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: "Basil L. Contovounesios" Subject: bug#57211: closed (Re: bug#57211: 29.0.50; generate-new-buffer-name sprintf format overflow warning) Message-ID: References: <9bd9ae82-8525-1d32-c4a1-5daaf909609a@cs.ucla.edu> <87ilmulqh0.fsf@tcd.ie> X-Gnu-PR-Message: they-closed 57211 X-Gnu-PR-Package: emacs Reply-To: 57211@debbugs.gnu.org Date: Sun, 14 Aug 2022 20:55:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1660510502-15209-1" This is a multi-part message in MIME format... ------------=_1660510502-15209-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #57211: 29.0.50; generate-new-buffer-name sprintf format overflow warning which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 57211@debbugs.gnu.org. --=20 57211: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D57211 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1660510502-15209-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 57211-done) by debbugs.gnu.org; 14 Aug 2022 20:54:17 +0000 Received: from localhost ([127.0.0.1]:39980 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNKcj-0003wJ-DV for submit@debbugs.gnu.org; Sun, 14 Aug 2022 16:54:17 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:55824) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNKch-0003w5-Hg for 57211-done@debbugs.gnu.org; Sun, 14 Aug 2022 16:54:16 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id BD60F16010A; Sun, 14 Aug 2022 13:54:09 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id FCuGh5l7Pv8m; Sun, 14 Aug 2022 13:54:08 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C137316010B; Sun, 14 Aug 2022 13:54:08 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id cGVawmk0Eirm; Sun, 14 Aug 2022 13:54:08 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 908B516010A; Sun, 14 Aug 2022 13:54:08 -0700 (PDT) Content-Type: multipart/mixed; boundary="------------cHBEzP78i3PWcCbbqqfXVX0u" Message-ID: <9bd9ae82-8525-1d32-c4a1-5daaf909609a@cs.ucla.edu> Date: Sun, 14 Aug 2022 13:54:08 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Content-Language: en-US To: "Basil L. Contovounesios" References: <87ilmulqh0.fsf@tcd.ie> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: bug#57211: 29.0.50; generate-new-buffer-name sprintf format overflow warning In-Reply-To: <87ilmulqh0.fsf@tcd.ie> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 57211-done Cc: 57211-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This is a multi-part message in MIME format. --------------cHBEzP78i3PWcCbbqqfXVX0u Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 8/14/22 09:50, Basil L. Contovounesios wrote: > Can the upper bound 9 ever be achieved? If so, how? If not, is this a > GCC bug? Either way, is there a way to pacify the warning? It can't be achieved, and it's arguably a GCC bug. I installed the attached to pacify GCC. > int i = r % 1000000; > > can the result of % ever exceed INT_MAX? No. On 8/14/22 11:59, Matt Armstrong wrote: > Gcc doesn't know that get_random() returns only non-negative numbers, > and the eassume() call doesn't seem to be enough to convince gcc this > fact, or gcc does not infer i is also non-negative. It's worse than that. Even if you add 'eassume (0 <= i && i < 1000000);" GCC still doesn't assume that the sprintf is in range. > Personally, I'd change this code to use a buffer > > INT_BUFSIZE_BOUND(int) + sizeof "-" The problem with overallocating buffers is not the memory loss (it's trivial, as you say), it's that later readers like me will wonder why the buffer is being overallocated, which is maintenance overhead. I installed the attached to pacify GCC while also attempting to not entirely mystify later readers. --------------cHBEzP78i3PWcCbbqqfXVX0u Content-Type: text/x-patch; charset=UTF-8; name="0001-Work-around-Bug-57211.patch" Content-Disposition: attachment; filename="0001-Work-around-Bug-57211.patch" Content-Transfer-Encoding: base64 RnJvbSAyMzU2MWY5NjY1NjA5YmNiNGNiZTg5YTk5M2E3MGVlY2NiZWM2MDBlIE1vbiBTZXAg MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBQYXVsIEVnZ2VydCA8ZWdnZXJ0QGNzLnVjbGEuZWR1 PgpEYXRlOiBTdW4sIDE0IEF1ZyAyMDIyIDEzOjQ4OjExIC0wNzAwClN1YmplY3Q6IFtQQVRD SF0gV29yayBhcm91bmQgQnVnIzU3MjExCgoqIHNyYy9idWZmZXIuYyAoRmdlbmVyYXRlX25l d19idWZmZXJfbmFtZSk6IEFsbG9jYXRlIGEgYmlnZ2VyIGJ1ZmZlci4KLS0tCiBzcmMvYnVm ZmVyLmMgfCAzICsrLQogMSBmaWxlIGNoYW5nZWQsIDIgaW5zZXJ0aW9ucygrKSwgMSBkZWxl dGlvbigtKQoKZGlmZiAtLWdpdCBhL3NyYy9idWZmZXIuYyBiL3NyYy9idWZmZXIuYwppbmRl eCA2YWI1MTZkNWY1Li45ODA2NmEyZWI2IDEwMDY0NAotLS0gYS9zcmMvYnVmZmVyLmMKKysr IGIvc3JjL2J1ZmZlci5jCkBAIC0xMTYwLDcgKzExNjAsOCBAQCBERUZVTiAoImdlbmVyYXRl LW5ldy1idWZmZXItbmFtZSIsIEZnZW5lcmF0ZV9uZXdfYnVmZmVyX25hbWUsCiAgICAgZ2Vu YmFzZSA9IG5hbWU7CiAgIGVsc2UKICAgICB7Ci0gICAgICBjaGFyIG51bWJlcltzaXplb2Yg Ii05OTk5OTkiXTsKKyAgICAgIGVudW0geyBidWdfNTI3MTEgPSB0cnVlIH07ICAvKiBodHRw czovL2J1Z3MuZ251Lm9yZy81NzIxMSAqLworICAgICAgY2hhciBudW1iZXJbYnVnXzUyNzEx ID8gSU5UX0JVRlNJWkVfQk9VTkQgKGludCkgKyAxIDogc2l6ZW9mICItOTk5OTk5Il07CiAg ICAgICBFTUFDU19JTlQgciA9IGdldF9yYW5kb20gKCk7CiAgICAgICBlYXNzdW1lICgwIDw9 IHIpOwogICAgICAgaW50IGkgPSByICUgMTAwMDAwMDsKLS0gCjIuMzQuMQoK --------------cHBEzP78i3PWcCbbqqfXVX0u-- ------------=_1660510502-15209-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 14 Aug 2022 16:50:13 +0000 Received: from localhost ([127.0.0.1]:39748 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNGoW-0006G9-UF for submit@debbugs.gnu.org; Sun, 14 Aug 2022 12:50:13 -0400 Received: from lists.gnu.org ([209.51.188.17]:56670) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oNGoU-0006Fy-Cp for submit@debbugs.gnu.org; Sun, 14 Aug 2022 12:50:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNGoU-0005tn-7g for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2022 12:50:10 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:46759) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oNGoR-0006aJ-PO for bug-gnu-emacs@gnu.org; Sun, 14 Aug 2022 12:50:09 -0400 Received: by mail-wr1-x434.google.com with SMTP id l4so6594682wrm.13 for ; Sun, 14 Aug 2022 09:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=content-transfer-encoding:mime-version:user-agent:message-id:date :subject:to:from:from:to:cc; bh=+QzLztkG+EeGaBUNXIeYd51HncWIoJ7pjOOnTwOV1zo=; b=BA/Xqwn9mgCBIfp+xk1pwYS7rpzTQ5u6dzO9rA/K7o5Nf2s1P+66CtcToLs2Z5klmu 9Pgl24Z23S1+iYKMdvruO6ptqAt7baqZz/+A0ulxwYRDxeEjc2YOnSempVyq2is2dZre mxLR88Z7gdk+ag07Udf0MFe9+19Cw9nju3yvFEycUpy1UcmCXI3ox0chinhOf55XU2j9 C9s4K/uBby0e10SxU4Y3Qc31zWoOXNXZwLmHhMhwlNyaWnoAYle5eu8uNM2jwO8nfCQL U74SdeXfydrJQ5he66gJ64rcc6HeZ+5IhgOccX8vdL/EyR6cwWsgJb/8PA23CMoZ2J8T MXFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:user-agent:message-id:date :subject:to:from:x-gm-message-state:from:to:cc; bh=+QzLztkG+EeGaBUNXIeYd51HncWIoJ7pjOOnTwOV1zo=; b=gtluEC4ZJNHui8x1Og+k0WYQANuUrTwWEh/PrimVphSr5vB5gb35eZZ7iTlHlEo3bH o2o8jjNYXs3QnayJMTJEDrHiMwlTGh3IT55123L5SGPhP6sKOfjHABx4yyRQ5rJzrMeN 0SfkKj6Y5BWZuSPzOLVEokUP4vHCWyXVhM70c908d5tmqVMICcOkquf8v00t2tA5qk6L NNgXgtG0r+pJHE5grzWDsxcaIEm7nBj4ChSLK32RRprWjoiDumu+OcSMdd26mTbDNR8G 37iyApMV3wkxa5H98ffbdodtJkx0N6yi/UXSVvffz0tF29GcDog3RXKX5DuxGGJ11IqM gTIg== X-Gm-Message-State: ACgBeo18hOnmu5zbwzn0dhuM0QSEnw9R6b8di0fScbYm5lK80dhUQhjx kdrxFyaBU6PXJgkqTmFDbWP4fGNMW4hyTw== X-Google-Smtp-Source: AA6agR7G/NfXuoMBV//wa2ldc3xILtwvU4Cv3Ir0+vRCXRvCNbJpbKgQBAXPaFcBe1/b+p2naE6O1A== X-Received: by 2002:a05:6000:1682:b0:221:599b:a41e with SMTP id y2-20020a056000168200b00221599ba41emr6571639wrd.522.1660495805311; Sun, 14 Aug 2022 09:50:05 -0700 (PDT) Received: from localhost ([2a02:587:322a:4bea:c3bc:c7ac:e79d:a903]) by smtp.gmail.com with ESMTPSA id v16-20020adfedd0000000b002217aed23b4sm4941911wro.12.2022.08.14.09.50.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Aug 2022 09:50:04 -0700 (PDT) From: "Basil L. Contovounesios" To: bug-gnu-emacs@gnu.org Subject: 29.0.50; generate-new-buffer-name sprintf format overflow warning X-Debbugs-Cc: Paul Eggert Date: Sun, 14 Aug 2022 19:50:03 +0300 Message-ID: <87ilmulqh0.fsf@tcd.ie> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=contovob@tcd.ie; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) Severity: minor Compiling with gcc (Debian 12.1.0-7) 12.1.0 and -Og, I get the following -Wformat-overflow warning: In file included from buffer.c:33: buffer.c: In function =E2=80=98Fgenerate_new_buffer_name=E2=80=99: buffer.c:1167:46: warning: =E2=80=98sprintf=E2=80=99 may write a terminatin= g nul past the end of the destination [-Wformat-overflow=3D] 1167 | AUTO_STRING_WITH_LEN (lnumber, number, sprintf (number, "-%d"= , i)); | ^~~~~~~~~~~~~~~~~~~~~~= ~~~~ lisp.h:5493:36: note: in definition of macro =E2=80=98AUTO_STRING_WITH_LEN= =E2=80=99 5493 | ((&(struct Lisp_String) {{{len, -1, 0, (unsigned char *) (s= tr)}}}), \ | ^~~ buffer.c:1167:46: note: =E2=80=98sprintf=E2=80=99 output between 3 and 9 by= tes into a destination of size 8 1167 | AUTO_STRING_WITH_LEN (lnumber, number, sprintf (number, "-%d"= , i)); | ^~~~~~~~~~~~~~~~~~~~~~= ~~~~ lisp.h:5493:36: note: in definition of macro =E2=80=98AUTO_STRING_WITH_LEN= =E2=80=99 5493 | ((&(struct Lisp_String) {{{len, -1, 0, (unsigned char *) (s= tr)}}}), \ | ^~~ Can the upper bound 9 ever be achieved? If so, how? If not, is this a GCC bug? Either way, is there a way to pacify the warning? I tried snprintf (number, sizeof number, ...) but got the same warning. BTW, in the preceding int i =3D r % 1000000; can the result of % ever exceed INT_MAX? And do we care either way? Thanks, --=20 Basil In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo versio= n 1.16.0, Xaw3d scroll bars) of 2022-08-14 built on tia Repository revision: 1d3fe256907d5e78a4acedd194e55db8ab952952 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101004 System Description: Debian GNU/Linux bookworm/sid Configured using: 'configure CC=3Dgcc-12 'CFLAGS=3D-Og -ggdb3' --config-cache --prefix=3D/home/blc/.local --enable-checking=3Dstructs --with-file-notification=3Dyes --with-x-toolkit=3Dlucid --with-x' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XAW3D XDBE XIM XINPUT2 XPM LUCID ZLIB Important settings: value of $LANG: en_IE.UTF-8 value of $XMODIFIERS: @im=3Dibus locale-coding-system: utf-8-unix ------------=_1660510502-15209-1--