summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMark Wielaard <[email protected]>2021-10-06 23:37:42 +0200
committerMark Wielaard <[email protected]>2021-10-06 23:41:00 +0200
commit3d9f12883d0c131bd4ab6045e1f60d3fe6d150ea (patch)
treeda305e8657570f2a4238a9aa0d44f812480efddb /src
parent260a3105cc0e378882110ba787cd58815183c454 (diff)
elflint.c: Don't dereference databits if bad
elflint.c: In function 'check_sections': elflint.c:4105:48: error: null pointer dereference [-Werror=null-dereference] 4105 | idx < databits->d_size && ! bad; | ~~~~~~~~^~~~~~~~ Fix this by testing for ! bad first. Reported-by: Jan-Benedict Glaw <[email protected]> Signed-off-by: Mark Wielaard <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog4
-rw-r--r--src/elflint.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 87b3dd46..316bcb6d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2021-10-06 Mark Wielaard <[email protected]>
+
+ * elflint.c (check_sections): Don't dereference databits if bad.
+
2021-09-09 Dmitry V. Levin <[email protected]>
* findtextrel.c: Include "libeu.h".
diff --git a/src/elflint.c b/src/elflint.c
index 1ce75684..ef7725ce 100644
--- a/src/elflint.c
+++ b/src/elflint.c
@@ -4102,7 +4102,7 @@ section [%2zu] '%s' has type NOBITS but is read from the file in segment of prog
bad = (databits == NULL
|| databits->d_size != shdr->sh_size);
for (size_t idx = 0;
- idx < databits->d_size && ! bad;
+ ! bad && idx < databits->d_size;
idx++)
bad = ((char *) databits->d_buf)[idx] != 0;