public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "mark at klomp dot org" <sourceware-bugzilla@sourceware.org>
To: elfutils-devel@sourceware.org
Subject: [Bug general/24068] 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
Date: Sun, 13 Jan 2019 17:02:00 -0000	[thread overview]
Message-ID: <bug-24068-10460-ttri8E98J3@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-24068-10460@http.sourceware.org/bugzilla/>

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

Mark Wielaard <mark at klomp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-01-13
                 CC|                            |mark at klomp dot org
     Ever confirmed|0                           |1

--- Comment #1 from Mark Wielaard <mark at klomp dot org> ---
This is weird. I cannot replicate with a standard build and gcc (GCC) 9.0.0
20190112 (experimental).

Aha, with -m32. hmmm. Odd.

So the issue seems to be that GCC doesn't realize digits is capped between 4
and 16. We could help with with something like:

diff --git a/src/readelf.c b/src/readelf.c
index 3a73710ff..83b700eee 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -10128,7 +10128,7 @@ print_debug_str_section (Dwfl_Module *dwflmod
__attribute__ ((unused)),
       ++digits;
       tmp >>= 4;
     }
-  digits = MAX (4, digits);
+  digits = MIN (16, MAX (4, digits));

   printf (gettext ("\nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"
                   " %*s  String\n"),

I that the correct fix though? Or is something else going on?
I don't understand why this is -m32 specific.

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

  reply	other threads:[~2019-01-13 17:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-06 15:58 [Bug general/24068] New: " marxin.liska at gmail dot com
2019-01-13 17:02 ` mark at klomp dot org [this message]
2019-01-14 10:26 ` [Bug general/24068] " marxin.liska at gmail dot com
2023-10-06 11:03 ` mark at klomp dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-24068-10460-ttri8E98J3@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).