Re: [PATCH 1/7] nwfilter: fix NULL pointer check in virNWFilterSnoopReqNew

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2012年11月28日 21:34, Ján Tomko wrote:
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 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c
index 807fd28..7703efd 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)) {

Good catch, but personally I'd like use brackets for "strlen" expression
too.

          virReportError(VIR_ERR_INTERNAL_ERROR,
                         _("virNWFilterSnoopReqNew called with invalid "
                           "key \"%s\" (%zu)"),
                         ifkey ? ifkey : "",
-                       strlen(ifkey));
+                       ifkey ? strlen(ifkey) : 0);
          return NULL;
      }


ACK.

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]