Blame SOURCES/python-ethtool-0.8-check-libnl-return-codes.patch

becf37
--- a/python-ethtool/etherinfo.c.orig	2014-01-13 13:38:58.716919961 +0100
becf37
+++ b/python-ethtool/etherinfo.c	2014-01-13 13:52:15.838033480 +0100
becf37
@@ -327,6 +327,9 @@
becf37
 	 */
becf37
 	if( ethinf->index < 0 ) {
becf37
 		link_cache = rtnl_link_alloc_cache(*data->nlc);
becf37
+        if( link_cache == NULL ) {
becf37
+            return 0;
becf37
+        }
becf37
 		ethinf->index = rtnl_link_name2i(link_cache, ethinf->device);
becf37
 		if( ethinf->index < 0 ) {
becf37
 			return 0;
becf37
@@ -339,6 +342,9 @@
becf37
 	case NLQRY_LINK:
becf37
 		/* Extract MAC/hardware address of the interface */
becf37
 		link_cache = rtnl_link_alloc_cache(*data->nlc);
becf37
+        if( link_cache == NULL ) {
becf37
+            return 0;
becf37
+        }
becf37
 		link = rtnl_link_alloc();
becf37
 		rtnl_link_set_ifindex(link, ethinf->index);
becf37
 		nl_cache_foreach_filter(link_cache, (struct nl_object *)link, callback_nl_link, ethinf);
becf37
@@ -350,7 +356,14 @@
becf37
 	case NLQRY_ADDR:
becf37
 		/* Extract IP address information */
becf37
 		addr_cache = rtnl_addr_alloc_cache(*data->nlc);
becf37
+        if( addr_cache == NULL ) {
becf37
+            return 0;
becf37
+        }
becf37
 		addr = rtnl_addr_alloc();
becf37
+        if( addr == NULL ) {
becf37
+            nl_cache_free(addr_cache);
becf37
+            return 0;
becf37
+        }
becf37
 		rtnl_addr_set_ifindex(addr, ethinf->index);
becf37
 
becf37
                 /* Make sure we don't have any old IPv6 addresses saved */
becf37
@@ -409,7 +422,9 @@
becf37
 
becf37
 	/* No earlier connections exists, establish a new one */
becf37
 	*data->nlc = nl_handle_alloc();
becf37
-	nl_connect(*data->nlc, NETLINK_ROUTE);
becf37
+	if( nl_connect(*data->nlc, NETLINK_ROUTE) != 0 ) {
becf37
+        return 0;
becf37
+    }
becf37
 	if( (*data->nlc != NULL) ) {
becf37
 		/* Force O_CLOEXEC flag on the NETLINK socket */
becf37
 		if( fcntl(nl_socket_get_fd(*data->nlc), F_SETFD, FD_CLOEXEC) == -1 ) {