]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
elfcmp: Don't call memcmp with possible NULL d_buf.
authorMark Wielaard <mjw@redhat.com>
Sat, 30 May 2015 21:55:50 +0000 (23:55 +0200)
committerMark Wielaard <mjw@redhat.com>
Fri, 5 Jun 2015 12:44:59 +0000 (14:44 +0200)
When d_size is zero d_buf might be NULL.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
src/ChangeLog
src/elfcmp.c

index 3161aa84ce3bcb43cc480afdd4cb51bfd3575843..59d87c8d43d559611cbd0320191f28790f49d765 100644 (file)
@@ -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,
index f8a4572d2c4fa4f10ef611aeacc70beef0f04cab..0250fbe39e3b56046bb40013d93651a29cac578e 100644 (file)
@@ -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)))
            {