]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
nlist: Fix pread() return value check
authorGuillem Jover <guillem@hadrons.org>
Sat, 15 Jun 2019 12:33:32 +0000 (14:33 +0200)
committerGuillem Jover <guillem@hadrons.org>
Thu, 8 Aug 2019 01:22:09 +0000 (03:22 +0200)
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 <daniel@elttam.com.au>
Based-on-patch-by: Daniel Hodson <daniel@elttam.com.au>
Signed-off-by: Guillem Jover <guillem@hadrons.org>
src/nlist.c

index e2a7949b33dcfc8a63d3e4dfa88ef0fc3dac9e4a..d01fa55ea27006ba0560c83cb6ccc0b4c79cd3bd 100644 (file)
@@ -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;
 
        /*