[binutils-gdb] readelf: avoid a possible divide by zero

Alan Modra amodra@sourceware.org
Sun Dec 19 11:48:48 GMT 2021


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=682351b932ba546b4451560917e819681c808f52

commit 682351b932ba546b4451560917e819681c808f52
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Dec 19 12:18:50 2021 +1030

    readelf: avoid a possible divide by zero
    
            * readelf.c (process_section_headers): Check SHT_RELR entsize.

Diff:
---
 binutils/readelf.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/binutils/readelf.c b/binutils/readelf.c
index 2225b7d9046..990b7597dd3 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -7093,6 +7093,10 @@ process_section_headers (Filedata * filedata)
 	    warn (_("Section '%s': zero-sized relocation section\n"), name);
 	  break;
 
+	case SHT_RELR:
+	  CHECK_ENTSIZE (section, i, Relr);
+	  break;
+
 	case SHT_NOTE:
 	case SHT_PROGBITS:
 	  /* Having a zero sized section is not illegal according to the


More information about the Binutils-cvs mailing list