Re: [PATCH] statd: Teach nfs_compare_sockaddr() to handle NULL arguments.

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

 



On Jan 25, 2010, at 11:59 AM, Steve Dickson wrote:
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).

It might be nice to document this quirk in from_local.c.

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

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

   Teach nfs_compare_sockaddr() to handle NULL arguments.

   Signed-off-by: Steve Dickson <steved@xxxxxxxxxx>

Reviewed-by: Chuck Lever <chuck.lever@xxxxxxxxxx>

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:
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com




--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux