zebra: untrusted array index (2) (Coverity 1470113)

This is a correction over 7f61ea7bd4 in order
to avoid the TAINTED_SCALAR Coverity warning (ending in "Untrusted array
index read"). This is equivalent to the previous commit, but avoiding
pointer arithmetic with tainted variables.

Signed-off-by: F. Aragon <paco@voltanet.io>
This commit is contained in:
paco 2018-06-22 17:14:57 +02:00
parent 7f61ea7bd4
commit 45981fda06
No known key found for this signature in database
GPG Key ID: FD112A8C7E6A5E4A

View File

@ -212,7 +212,9 @@ static int zebra_ns_notify_read(struct thread *t)
continue;
if (event->mask & IN_DELETE)
return zebra_ns_delete(event->name);
if (&event->name[event->len] >= &buf[sizeof(buf)]) {
if (offsetof(struct inotify_event, name) + event->len
>= sizeof(buf)) {
zlog_err("NS notify read: buffer underflow");
break;
}