From: Mark Wielaard <mjw@redhat.com>
To: elfutils-devel@lists.fedorahosted.org
Subject: [PATCH] libdwfl: Fix wrong type to make gcc -fsanitize=undefined happy.
Date: Tue, 21 Apr 2015 16:01:15 +0200 [thread overview]
Message-ID: <1429624875-19909-1-git-send-email-mjw@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1271 bytes --]
gcc -fsanitize=undefined would warn about calling dwfl_error accessing
the error string array: elfutils/libdwfl/dwfl_error.c:156:60:
runtime error: index 385 out of bounds for type 'char [9]'
This is because it thought we went beyond error string zero "no error",
which is indeed 9 chars. "Correct" the type of the pointer to make
ubsan happy.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
libdwfl/ChangeLog | 4 ++++
libdwfl/dwfl_error.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index d4cd3f5..90c0a04 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,7 @@
+2015-04-21 Mark Wielaard <mjw@redhat.com>
+
+ * dwfl_error.c (msgstr): Define as const char *.
+
2015-04-02 Mark Wielaard <mjw@redhat.com>
* segment.c (insert): Check correct number of lookup_elts.
diff --git a/libdwfl/dwfl_error.c b/libdwfl/dwfl_error.c
index d9ca9e7..c3648c0 100644
--- a/libdwfl/dwfl_error.c
+++ b/libdwfl/dwfl_error.c
@@ -65,7 +65,7 @@ static const struct msgtable
DWFL_ERRORS
#undef DWFL_ERROR
};
-#define msgstr (&msgtable.msg_NOERROR[0])
+#define msgstr ((const char *) &msgtable)
static const uint_fast16_t msgidx[] =
{
--
2.1.0
next reply other threads:[~2015-04-21 14:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-21 14:01 Mark Wielaard [this message]
2015-04-21 20:26 Roland McGrath
2015-04-22 11:59 Mark Wielaard
2015-04-23 15:06 Alexander Cherepanov
2015-04-23 17:04 Roland McGrath
2015-04-23 17:05 Roland McGrath
2015-04-23 17:49 Mark Wielaard
2015-04-28 15:37 Mark Wielaard
2015-05-06 10:00 Mark Wielaard
2015-05-06 20:50 Roland McGrath
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=1429624875-19909-1-git-send-email-mjw@redhat.com \
--to=mjw@redhat.com \
--cc=elfutils-devel@lists.fedorahosted.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).