mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 12:54:27 +00:00
libpfctl: handle allocation failure
While it's unlikely for userspace to fail to allocate memory it is still possible. Handle malloc() returning NULL. Reported by: Bill Meeks <bill@themeeks.net> MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate")
This commit is contained in:
parent
6c46ebb05d
commit
33d55d0d0f
|
@ -78,6 +78,11 @@ pfctl_do_ioctl(int dev, uint cmd, size_t size, nvlist_t **nvl)
|
|||
|
||||
retry:
|
||||
nv.data = malloc(size);
|
||||
if (nv.data == NULL) {
|
||||
ret = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(nv.data, data, nvlen);
|
||||
|
||||
nv.len = nvlen;
|
||||
|
@ -229,6 +234,8 @@ _pfctl_get_status_counters(const nvlist_t *nvl,
|
|||
struct pfctl_status_counter *c;
|
||||
|
||||
c = malloc(sizeof(*c));
|
||||
if (c == NULL)
|
||||
continue;
|
||||
|
||||
c->id = ids[i];
|
||||
c->counter = counts[i];
|
||||
|
|
Loading…
Reference in a new issue