Since all values are 64bit, not 32bit as in other hashes, we need to
explicitly check for overflow.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
+2014-11-30 Mark Wielaard <mjw@redhat.com>
+
+ * readelf.c (handle_sysv_hash64): Fix overflow check.
+
2014-11-28 Mark Wielaard <mjw@redhat.com>
* readelf.c (handle_relocs_rel): Don't reuse destshdr to store
Elf64_Xword nbucket = ((Elf64_Xword *) data->d_buf)[0];
Elf64_Xword nchain = ((Elf64_Xword *) data->d_buf)[1];
- uint64_t used_buf = (2ULL + nchain + nbucket) * sizeof (Elf64_Xword);
- if (used_buf > data->d_size)
+ uint64_t maxwords = data->d_size / sizeof (Elf64_Xword);
+ if (maxwords < 2
+ || maxwords - 2 < nbucket
+ || maxwords - 2 - nbucket < nchain)
goto invalid_data;
Elf64_Xword *bucket = &((Elf64_Xword *) data->d_buf)[2];