]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
nlist: Check whether the nl argument is not NULL
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)
This prevents programming errors.

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>
man/nlist.3bsd
src/nlist.c

index 7dd2377e64c4516b64aa02509c9a5f4ecd786975..beb32a33ef697f72a6b495548edf60f7411e5273 100644 (file)
@@ -72,7 +72,10 @@ The last entry in the list is always
 The number of invalid entries is returned if successful; otherwise,
 if the file
 .Fa filename
-does not exist or is not executable, the returned value is \-1.
+does not exist or is not executable,
+or the nl pointer is
+.Dv NULL ,
+the returned value is \-1.
 .Sh SEE ALSO
 .Xr elf 5
 .Sh HISTORY
index 0932f59fa79e05ea16da701e8fb68248a515ebc4..776d3157404e1ef95405d9541798ddc7a0839648 100644 (file)
@@ -258,6 +258,10 @@ nlist(const char *name, struct nlist *list)
 {
        int fd, n;
 
+       if (list == NULL) {
+               errno = EINVAL;
+               return (-1);
+       }
        fd = open(name, O_RDONLY, 0);
        if (fd < 0)
                return (-1);