bug-groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #60964] [PATCH] hpftodit.cpp: warnings about a too short array


From: Bjarni Ingi Gislason
Subject: [bug #60964] [PATCH] hpftodit.cpp: warnings about a too short array
Date: Sat, 24 Jul 2021 07:51:48 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0

URL:
  <https://savannah.gnu.org/bugs/?60964>

                 Summary: [PATCH] hpftodit.cpp: warnings about a too short
array
                 Project: GNU troff
            Submitted by: bjarniig
            Submitted on: Sat 24 Jul 2021 11:51:45 AM UTC
                Category: Utilities
                Severity: 3 - Normal
              Item Group: Warning/Suspicious behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None

    _______________________________________________________

Details:

>From 186ecbae7145c8ff2a45cc409242725a309460f5 Mon Sep 17 00:00:00 2001
From: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Date: Sat, 24 Jul 2021 11:02:43 +0000
Subject: [PATCH] hpftodit.cpp: warnings about a too short array

../src/utils/hpftodit/hpftodit.cpp: In function 'char* show_symset(unsigned
int)':
../src/utils/hpftodit/hpftodit.cpp:1261:25: warning: '%d' directive writing
between 1 and 9 bytes into a region of size 8 [-Wformat-overflow=]
 1261 |    sprintf(symset_str, "%d%c", symset / 32, (symset & 31) + 64);
      |                         ^~
../src/utils/hpftodit/hpftodit.cpp:1261:24: note: directive argument in the
range [0, 134217727]
 1261 |    sprintf(symset_str, "%d%c", symset / 32, (symset & 31) + 64);
      |                        ^~~~~~
In file included from /usr/include/stdio.h:867,
                 from ./lib/stdio.h:43,
                 from ../src/include/getopt.h:35,
                 from ../src/include/lib.h:38,
                 from ../src/utils/hpftodit/hpftodit.cpp:27:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:36:34: note:
'__builtin___sprintf_chk' output between 3 and 11 bytes into a destination of
size 8
   36 |   return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
      |          ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |       __bos (__s), __fmt, __va_arg_pack ());
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  This popped up after adding the options "-ggdb -Og" to CFLAGS.

FLAGS_COMMON="\
-Wall -Wextra -Wformat=2  \
-Wstringop-overflow=4 \
-Wshadow=global -Wredundant-decls \
-Wunused \
-Wunused-parameter \
-fsanitize=signed-integer-overflow \
-fsanitize-undefined-trap-on-error \
-fstack-protector-strong -fno-common \
-fstack-clash-protection \
-ftrapv \
-funsigned-char \
-fvar-tracking-assignments  \
-ggdb -Og \
-D_FORTIFY_SOURCE=2 \
"

CFLAGS="\
$FLAGS_COMMON \
-Wmissing-prototypes \
-Wold-style-definition -Wstrict-prototypes  \
-Wold-style-declaration  \
-std=c2x"

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
---
 src/utils/hpftodit/hpftodit.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/utils/hpftodit/hpftodit.cpp
b/src/utils/hpftodit/hpftodit.cpp
index 5c219113..8b330308 100644
--- a/src/utils/hpftodit/hpftodit.cpp
+++ b/src/utils/hpftodit/hpftodit.cpp
@@ -1256,7 +1256,7 @@ dump_symbols(int tfm_type)
 static char *
 show_symset(unsigned int symset)
 {
-   static char symset_str[8];
+   static char symset_str[11];
 
    sprintf(symset_str, "%d%c", symset / 32, (symset & 31) + 64);
    return symset_str;
-- 
2.30.2






    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60964>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]