This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 4/4] elfcmp: Don't call memcmp with possible NULL d_buf.


When d_size is zero d_buf might be NULL.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
---
 src/ChangeLog | 4 ++++
 src/elfcmp.c  | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index 3161aa8..59d87c8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2015-05-30  Mark Wielaard  <mjw@redhat.com>
+
+	* elfcmp.c (main): Only call memcmp when d_size != 0.
+
 2015-05-23  Mark Wielaard  <mjw@redhat.com>
 
 	* Makefile.am: Define ldgeneric, readelf, nm, size, strip, elflint,
diff --git a/src/elfcmp.c b/src/elfcmp.c
index f8a4572..0250fbe 100644
--- a/src/elfcmp.c
+++ b/src/elfcmp.c
@@ -1,5 +1,5 @@
 /* Compare relevant content of two ELF files.
-   Copyright (C) 2005-2012, 2014 Red Hat, Inc.
+   Copyright (C) 2005-2012, 2014, 2015 Red Hat, Inc.
    This file is part of elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2005.
 
@@ -511,6 +511,7 @@ cannot read note section [%zu] '%s' in '%s': %s"),
 
 	  if (unlikely (data1->d_size != data2->d_size
 			|| (shdr1->sh_type != SHT_NOBITS
+			    && data1->d_size != 0
 			    && memcmp (data1->d_buf, data2->d_buf,
 				       data1->d_size) != 0)))
 	    {
-- 
2.1.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]