statd: Teach nfs_compare_sockaddr() to handle NULL arguments.
Subsystems (2)
PATCH 1/1 statd: Teach nfs_compare_sockaddr() to handle NULL arguments.
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 <[email protected]> Date: Mon Jan 25 11:42:36 2010 -0500
Teach nfs_compare_sockaddr() to handle NULL arguments.
support/include/sockaddr.h +4 -0
@@ -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 :
Chuck Lever
Reviewed-byQuoted 3 lines · Steve Dickson
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.
Quoted 9 lines
So this patch makes
nfs_compare_sockaddr()return false if either one of its arguments is null..Author: Steve Dickson <[email protected]> Date: Mon Jan 25 11:42:36 2010 -0500Teach
nfs_compare_sockaddr()to handle NULL arguments.Signed-off-by Steve Dickson <[email protected]>
Quoted 27 lines
support/include/sockaddr.h +1
-0@@ -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
_Boolnfs_compare_sockaddr(const struct sockaddr *sa1, const struct sockaddr *sa2){support/include/sockaddr.h +3
-0+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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Quoted 7 lines · Steve Dickson
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..
Committed...
steved.
Quoted 10 lines · Chuck Lever
Quoted 3 lines · Steve Dickson
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.Quoted 3 lines
So this patch makes
nfs_compare_sockaddr()return false if either one of its arguments is null..
Quoted 8 lines
Quoted 6 lines
Author: Steve Dickson <[email protected]> Date: Mon Jan 25 11:42:36 2010 -0500Teach
nfs_compare_sockaddr()to handle NULL arguments.Signed-off-by Steve Dickson <[email protected]>Reviewed-by Chuck Lever <[email protected]>
Hrm. On second thought....
Catching these in nfs_compare_sockaddr() will make it harder to find NULL pointer bugs in other parts of the code, I would think. Instead, maybe you should trap these in from_local.c. That way you document the quirk (as above) as well.
Quoted 39 lines
Quoted 27 lines
support/include/sockaddr.h +1
-0@@ -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
_Boolnfs_compare_sockaddr(const struct sockaddr *sa1, const struct sockaddr *sa2){support/include/sockaddr.h +3
-0+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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlSignature · 10 lines
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 [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com