From: Sunil N. <sun...@ni...> - 2019-04-16 08:34:15
|
Hi, Following diff fixes modulo by 0 issue found by Coverity scan. _libelf_msize() could return 0 on version error. Needs a review of other callers that assign return value of _libelf_msize() unchecked in elf_update.c. diff --git a/libelf/elf_update.c b/libelf/elf_update.c index 51b3108b..023a229e 100644 --- a/libelf/elf_update.c +++ b/libelf/elf_update.c @@ -226,6 +226,7 @@ _libelf_compute_section_extents(Elf *e, Elf_Scn *s, off_t rc) * memory size of the underlying type. */ msz = _libelf_msize(d->d_type, ec, e->e_version); + assert(msz > 0); if (d->d_size % msz) { LIBELF_SET_ERROR(DATA, 0); return (0); @@ -801,6 +802,7 @@ _libelf_write_scn(Elf *e, unsigned char *nf, struct _Elf_Extent *ex) d = &ld->d_data; msz = _libelf_msize(d->d_type, ec, e->e_version); + assert(msz > 0); if ((uint64_t) rc < sh_off + d->d_off) (void) memset(nf + rc, |