Commit 3aaedb12 authored by Guillem Jover's avatar Guillem Jover

nlist: Check whether the nl argument is not NULL

This prevents programming errors.
Reported-by: 's avatarDaniel Hodson <daniel@elttam.com.au>
Based-on-patch-by: 's avatarDaniel Hodson <daniel@elttam.com.au>
Signed-off-by: Guillem Jover's avatarGuillem Jover <guillem@hadrons.org>
parent 2c754f43
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment