[Bug general/24068] New: readelf.c:10152:15: error: ‘%*llx’ directive output between 4 and 2147483647 bytes may cause result to exceed ‘INT_MAX’ [-Werror=format-overflow=] with -m32

marxin.liska at gmail dot com sourceware-bugzilla@sourceware.org
Sun Jan 6 15:58:00 GMT 2019


https://sourceware.org/bugzilla/show_bug.cgi?id=24068

            Bug ID: 24068
           Summary: readelf.c:10152:15: error: ‘%*llx’ directive output
                    between 4 and 2147483647 bytes may cause result to
                    exceed ‘INT_MAX’ [-Werror=format-overflow=] with -m32
           Product: elfutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: general
          Assignee: unassigned at sourceware dot org
          Reporter: marxin.liska at gmail dot com
                CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

Using latest GCC and -m32 (on x86_64-linux-gnu), one can see:

$ gcc -D_GNU_SOURCE -DHAVE_CONFIG_H -DLOCALEDIR='"/usr/local/share/locale"' 
-DDEBUGPRED=0 -DSRCDIR=\"/home/marxin/Programming/elfutils/src\"
-DOBJDIR=\"/home/marxin/Programming/elfutils/src\" -I. -I..  -I. -I. -I../lib
-I.. -I./../libelf -I./../libebl -I./../libdw -I./../libdwelf -I./../libdwfl
-I./../libasm  -std=gnu99 -Wall -Wshadow -Wformat=2 -Wold-style-definition
-Wstrict-prototypes -Wtrampolines -Wlogical-op -Wduplicated-cond
-Wnull-dereference -Wimplicit-fallthrough=5 -Werror -Wunused -Wextra   
-D_FORTIFY_SOURCE=2 -g -O2 -MT readelf.o -MD -MP -MF .deps/readelf.Tpo -c -o
readelf.o readelf.c -m32
readelf.c: In function ‘print_debug_str_section’:
readelf.c:10152:15: error: ‘%*llx’ directive output between 4 and 2147483647
bytes may cause result to exceed ‘INT_MAX’ [-Werror=format-overflow=]
10152 |       printf (" [%*" PRIx64 "]  \"%s\"\n", digits, (uint64_t) offset,
str);
      |               ^~~~~~
readelf.c:10152:18: note: format string is defined here
10152 |       printf (" [%*" PRIx64 "]  \"%s\"\n", digits, (uint64_t) offset,
str);
readelf.c:10152:15: note: directive argument in the range [0,
18446744073709551614]
10152 |       printf (" [%*" PRIx64 "]  \"%s\"\n", digits, (uint64_t) offset,
str);
      |               ^~~~~~
cc1: all warnings being treated as errors

Can you please check that?

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Elfutils-devel mailing list