public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/2] Don't overflow in __libdw_in_section
@ 2017-05-20 16:08 Ulf Hermann
  0 siblings, 0 replies; only message in thread
From: Ulf Hermann @ 2017-05-20 16:08 UTC (permalink / raw)
  To: elfutils-devel

This exposes a bug in dwarf_formstring as detected by the dwarf-getmacros
test. We cannot unconditionally assume that a string is in either the
IDX_debug_info or the IDX_debug_types section as determined by
cu_sec_idx.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
 libdw/ChangeLog | 4 ++++
 libdw/libdwP.h  | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 665c232..a5c1ff0 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,9 @@
 2017-05-09  Ulf Hermann  <ulf.hermann@qt.io>
 
+	* libdwP.h: Fix check for the upper border of the range in __libdw_in_section.
+
+2017-05-09  Ulf Hermann  <ulf.hermann@qt.io>
+
 	* dwarf_getmacros.c: Initialize type_offset of the fake CU.
 
 2017-02-28  Ulf Hermann  <ulf.hermann@qt.io>
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index cefcafd..b87a94b 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -642,7 +642,8 @@ __libdw_in_section (Dwarf *dbg, int sec_index,
   if (data == NULL)
     return false;
   if (unlikely (addr < data->d_buf)
-      || unlikely (data->d_size - (addr - data->d_buf) < size))
+      || unlikely (data->d_size < size)
+      || unlikely ((size_t)(addr - data->d_buf) > data->d_size - size))
     {
       __libdw_seterrno (DWARF_E_INVALID_OFFSET);
       return false;
-- 
2.1.4

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-09 16:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-20 16:08 [PATCH 2/2] Don't overflow in __libdw_in_section Ulf Hermann

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).