public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Steve Dickson <SteveD@redhat.com>
To: Linux NFS Mailing list <linux-nfs@vger.kernel.org>
Subject: [PATCH] statd: Teach nfs_compare_sockaddr() to handle NULL arguments.
Date: Mon, 25 Jan 2010 11:59:23 -0500	[thread overview]
Message-ID: <4B5DCDEB.60708@RedHat.com> (raw)

It seems the list of interfaces returned by getifaddrs()
can contain a null address pointer (ifa->ifa_addr) even though 
the interface is marked UP (this happens with the tun0 interface).

So this patch makes nfs_compare_sockaddr() return false
if either one of its arguments is null..

Author: Steve Dickson <steved@redhat.com>
Date:   Mon Jan 25 11:42:36 2010 -0500

    Teach nfs_compare_sockaddr() to handle NULL arguments.
    
    Signed-off-by: Steve Dickson <steved@redhat.com>

diff --git a/support/include/sockaddr.h b/support/include/sockaddr.h
index 732514b..9af2543 100644
--- a/support/include/sockaddr.h
+++ b/support/include/sockaddr.h
@@ -20,6 +20,7 @@
 #ifndef NFS_UTILS_SOCKADDR_H
 #define NFS_UTILS_SOCKADDR_H
 
+#include <libio.h>
 #include <stdbool.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -223,6 +224,9 @@ compare_sockaddr6(__attribute__ ((unused)) const struct sockaddr *sa1,
 static inline _Bool
 nfs_compare_sockaddr(const struct sockaddr *sa1, const struct sockaddr *sa2)
 {
+	if (sa1 == NULL || sa2 == NULL)
+		return false;
+
 	if (sa1->sa_family == sa2->sa_family)
 		switch (sa1->sa_family) {
 		case AF_INET:

             reply	other threads:[~2010-01-25 16:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-25 16:59 Steve Dickson [this message]
     [not found] ` <4B5DCDEB.60708-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2010-01-25 18:05   ` [PATCH] statd: Teach nfs_compare_sockaddr() to handle NULL arguments Chuck Lever
2010-01-25 18:18     ` Chuck Lever
2010-01-25 18:10   ` Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B5DCDEB.60708@RedHat.com \
    --to=steved@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox