Subject: bug#42656: closed (Re: bug#42656: term.c:1405:25: warning:‘%d’ directive writing between 2 and 10 bytes into a region of size 3)

From: [email-masked] (GNU bug Tracking System)
Date: Tue, 25 Aug 2020 13:39:04 +0000

Your bug report

#42656: term.c:1405:25: warning: ‘%d’ directive writing between 2 and 10 bytes into a region of size 3

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 [email-masked].

-- 
42656: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=42656
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#42656: term.c:1405:25: warning: ‘%d’ directive writing between 2 and 10 bytes into a region of size 3
From: Stefan Kangas <[email-masked]>
To: Paul Eggert <[email-masked]>
Cc: Jeffrey Walton <[email-masked]>, [email-masked]
Date: Tue, 25 Aug 2020 06:38:43 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Paul Eggert <[email-masked]> writes:

> I regularly get messages like that from old versions of GCC. It's better to
> ignore such messages, as we shouldn't clutter up the code merely to pacify older
> (or buggy) compilers.
>
> You can build with --disable-gcc-warnings to suppress the annoyances with older
> compilers (if you're building from Git, that is; you shouldn't need to specify
> anything if building from a tarball).

I think the consensus here is that this is a compiler bug that should be
ignored.  I'm therefore closing this bug report.

Subject: term.c:1405:25: warning: ‘%d’ directive writing between 2 and 10 bytes into a region of size 3
From: Jeffrey Walton <[email-masked]>
To: [email-masked]
Date: Sat, 1 Aug 2020 15:27:48 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

I think this can be cleared by clamping the argument.

term.c: In function ‘term_get_fkeys_1’:
term.c:1405:25: warning: ‘%d’ directive writing between 2 and 10 bytes
into a region of size 3 [-Wformat-overflow=]
        sprintf (fkey, "f%d", i);
                         ^~
term.c:1405:23: note: directive argument in the range [11, 2147483646]
        sprintf (fkey, "f%d", i);
                       ^~~~~
In file included from /usr/include/stdio.h:862:0,
                 from ../lib/stdio.h:43,
                 from termchar.h:22,
                 from term.c:31:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:33:10: note:
‘__builtin___sprintf_chk’ output between 4 and 12 bytes into a
destination of size 4
   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,