From cb022152529f560183afd4e443773b3209085576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Wed, 28 Nov 2012 14:34:45 +0100 Subject: [PATCH] nwfilter: fix NULL pointer check in virNWFilterSnoopReqNew This can't lead to a crash since virNWFilterSnoopReqNew is only called with a static array as the argument, but if we check for NULL we should do it right. --- src/nwfilter/nwfilter_dhcpsnoop.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index 807fd28825..3321d0bf23 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -573,12 +573,12 @@ virNWFilterSnoopReqNew(const char *ifkey) { virNWFilterSnoopReqPtr req; - if (ifkey == NULL || strlen(ifkey) != VIR_IFKEY_LEN - 1) { + if (ifkey == NULL || (ifkey && (strlen(ifkey) != VIR_IFKEY_LEN - 1))) { virReportError(VIR_ERR_INTERNAL_ERROR, _("virNWFilterSnoopReqNew called with invalid " "key \"%s\" (%zu)"), ifkey ? ifkey : "", - strlen(ifkey)); + ifkey ? strlen(ifkey) : 0); return NULL; }