From: Guillem Jover Date: Sat, 15 Jun 2019 12:33:32 +0000 (+0200) Subject: nlist: Fix pread() return value check X-Git-Tag: 0.10.0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce53f7c25f64a694550886113154ce0b201be58f;p=thirdparty%2Flibbsd.git nlist: Fix pread() return value check We should check for partial reads, and not continue in those cases, as we are not retrying them, otherwise we might end up operating on uninitialized data. Reported-by: Daniel Hodson Based-on-patch-by: Daniel Hodson Signed-off-by: Guillem Jover --- diff --git a/src/nlist.c b/src/nlist.c index e2a7949..d01fa55 100644 --- a/src/nlist.c +++ b/src/nlist.c @@ -161,7 +161,7 @@ __fdnlist(int fd, struct nlist *list) return (-1); /* Load section header table. */ - if (pread(fd, shdr, (size_t)shdr_size, (off_t)ehdr.e_shoff) < 0) + if (pread(fd, shdr, (size_t)shdr_size, (off_t)ehdr.e_shoff) != (ssize_t)shdr_size) goto done; /* @@ -198,7 +198,7 @@ __fdnlist(int fd, struct nlist *list) if (strtab == NULL) goto done; - if (pread(fd, strtab, (size_t)symstrsize, (off_t)symstroff) < 0) + if (pread(fd, strtab, (size_t)symstrsize, (off_t)symstroff) != (ssize_t)symstrsize) goto done; /*