From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============4826065567076441820==" MIME-Version: 1.0 From: Mark Wielaard 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 Message-ID: <1429624875-19909-1-git-send-email-mjw@redhat.com> --===============4826065567076441820== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable gcc -fsanitize=3Dundefined 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 --- 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 + + * dwfl_error.c (msgstr): Define as const char *. + 2015-04-02 Mark Wielaard = * 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[] =3D { -- = 2.1.0 --===============4826065567076441820==--