public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] statd: Teach nfs_compare_sockaddr() to handle NULL arguments.
@ 2010-01-25 16:59 Steve Dickson
       [not found] ` <4B5DCDEB.60708-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Steve Dickson @ 2010-01-25 16:59 UTC (permalink / raw)
  To: Linux NFS Mailing list

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:

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-01-25 18:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-25 16:59 [PATCH] statd: Teach nfs_compare_sockaddr() to handle NULL arguments Steve Dickson
     [not found] ` <4B5DCDEB.60708-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2010-01-25 18:05   ` Chuck Lever
2010-01-25 18:18     ` Chuck Lever
2010-01-25 18:10   ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox