Re: [Xen-devel] [PATCH 4/4] libelf: treat phdr and shdr similarly

2016-12-06 Thread Roger Pau Monné
On Tue, Dec 06, 2016 at 04:53:12AM -0700, Jan Beulich wrote: > Just like elf_shdr_count(), elf_phdr_count() better bounds checks the > value. > > Add table entry size checks to elf_init(). > > Also both program and section headers are optional, and hence their > checking better is done conditiona

Re: [Xen-devel] [PATCH 4/4] libelf: treat phdr and shdr similarly

2016-12-06 Thread Konrad Rzeszutek Wilk
On Tue, Dec 06, 2016 at 06:37:30AM -0700, Jan Beulich wrote: > >>> On 06.12.16 at 14:27, wrote: > >> unsigned elf_shdr_count(struct elf_binary *elf) > >> { > >> unsigned count = elf_uval(elf, elf->ehdr, e_shnum); > >> -uint64_t max = elf->size / sizeof(Elf32_Shdr); > >> +uint64_t ma

Re: [Xen-devel] [PATCH 4/4] libelf: treat phdr and shdr similarly

2016-12-06 Thread Jan Beulich
>>> On 06.12.16 at 14:27, wrote: >> unsigned elf_shdr_count(struct elf_binary *elf) >> { >> unsigned count = elf_uval(elf, elf->ehdr, e_shnum); >> -uint64_t max = elf->size / sizeof(Elf32_Shdr); >> +uint64_t max; >> >> +if ( !count ) >> +return 0; >> +max = elf->si

Re: [Xen-devel] [PATCH 4/4] libelf: treat phdr and shdr similarly

2016-12-06 Thread Konrad Rzeszutek Wilk
. snip.. All that above makes sense (and please put Reviewed-by from me on it), but this: > unsigned elf_shdr_count(struct elf_binary *elf) > { > unsigned count = elf_uval(elf, elf->ehdr, e_shnum); > -uint64_t max = elf->size / sizeof(Elf32_Shdr); > +uint64_t max; > > +if ( !c

[Xen-devel] [PATCH 4/4] libelf: treat phdr and shdr similarly

2016-12-06 Thread Jan Beulich
Just like elf_shdr_count(), elf_phdr_count() better bounds checks the value. Add table entry size checks to elf_init(). Also both program and section headers are optional, and hence their checking better is done conditionally only when any such headers are present. Signed-off-by: Jan Beulich -