Blame SOURCES/rpcbind-1.2.5-covscan-resource-leaks.patch

6657fd
diff -up rpcbind-1.2.5/src/rpcbind.c.orig rpcbind-1.2.5/src/rpcbind.c
6657fd
--- rpcbind-1.2.5/src/rpcbind.c.orig	2020-02-06 14:19:34.199330296 -0500
6657fd
+++ rpcbind-1.2.5/src/rpcbind.c	2020-02-06 14:20:19.069973902 -0500
6657fd
@@ -350,7 +350,7 @@ init_transport(struct netconfig *nconf)
6657fd
 {
6657fd
 	int fd = -1;
6657fd
 	struct t_bind taddr;
6657fd
-	struct addrinfo hints, *res;
6657fd
+	struct addrinfo hints, *res = NULL;
6657fd
 	struct __rpc_sockinfo si;
6657fd
 	SVCXPRT	*my_xprt = NULL;
6657fd
 	int status;	/* bound checking ? */
6657fd
@@ -827,8 +827,12 @@ got_socket:
6657fd
 	}
6657fd
 #endif
6657fd
 
6657fd
+	if (res != NULL)
6657fd
+		freeaddrinfo(res);
6657fd
 	return (0);
6657fd
 error:
6657fd
+	if (res != NULL)
6657fd
+		freeaddrinfo(res);
6657fd
 	close(fd);
6657fd
 	return (1);
6657fd
 }
6657fd
diff -up rpcbind-1.2.5/src/rpcb_stat.c.orig rpcbind-1.2.5/src/rpcb_stat.c
6657fd
--- rpcbind-1.2.5/src/rpcb_stat.c.orig	2018-08-15 10:51:19.000000000 -0400
6657fd
+++ rpcbind-1.2.5/src/rpcb_stat.c	2020-02-06 14:20:19.073973959 -0500
6657fd
@@ -151,7 +151,7 @@ rpcbs_rmtcall(rpcvers_t rtype, rpcproc_t
6657fd
 	rpcbs_rmtcalllist *rl;
6657fd
 	struct netconfig *nconf;
6657fd
 
6657fd
-	if (rtype > RPCBVERS_STAT)
6657fd
+	if (rtype >= RPCBVERS_STAT)
6657fd
 		return;
6657fd
 	for (rl = inf[rtype].rmtinfo; rl; rl = rl->next) {
6657fd
 
6657fd
diff -up rpcbind-1.2.5/src/rpcinfo.c.orig rpcbind-1.2.5/src/rpcinfo.c
6657fd
--- rpcbind-1.2.5/src/rpcinfo.c.orig	2020-02-06 14:19:34.193330210 -0500
6657fd
+++ rpcbind-1.2.5/src/rpcinfo.c	2020-02-06 14:20:19.073973959 -0500
6657fd
@@ -693,11 +693,11 @@ reply_proc (res, who, nconf)
6657fd
     }
6657fd
   if (!(uaddr = taddr2uaddr (nconf, who)))
6657fd
     {
6657fd
-      uaddr = UNKNOWN;
6657fd
+      printf ("%s\t%s\n", UNKNOWN, hostname);
6657fd
+    } else {
6657fd
+      printf ("%s\t%s\n", uaddr, hostname);
6657fd
+      free ((char *) uaddr);
6657fd
     }
6657fd
-  printf ("%s\t%s\n", uaddr, hostname);
6657fd
-  if (strcmp (uaddr, UNKNOWN))
6657fd
-    free ((char *) uaddr);
6657fd
   return (FALSE);
6657fd
 }
6657fd
 
6657fd
diff -up rpcbind-1.2.5/src/util.c.orig rpcbind-1.2.5/src/util.c
6657fd
--- rpcbind-1.2.5/src/util.c.orig	2020-02-06 14:20:51.564439986 -0500
6657fd
+++ rpcbind-1.2.5/src/util.c	2020-02-06 14:20:39.994274027 -0500
6657fd
@@ -322,13 +322,20 @@ network_init()
6657fd
 	/*
6657fd
 	 * Now join the RPC ipv6 multicast group on all interfaces.
6657fd
 	 */
6657fd
-	if (getifaddrs(&ifp) < 0)
6657fd
+	if (getifaddrs(&ifp) < 0) {
6657fd
+		freeaddrinfo (res);
6657fd
 		return;
6657fd
-
6657fd
+	}
6657fd
 	mreq6.ipv6mr_interface = 0;
6657fd
 	inet_pton(AF_INET6, RPCB_MULTICAST_ADDR, &mreq6.ipv6mr_multiaddr);
6657fd
 
6657fd
 	s = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
6657fd
+	if (s < 0) {
6657fd
+	    if (debugging)
6657fd
+		    fprintf(stderr, "socket(AF_INET6) failed: %s\n", strerror(errno));
6657fd
+	    freeaddrinfo (res);
6657fd
+	    return;
6657fd
+	}
6657fd
 
6657fd
 	/*
6657fd
 	 * Loop through all interfaces. For each IPv6 multicast-capable
6657fd
@@ -351,9 +358,9 @@ network_init()
6657fd
 			if (debugging)
6657fd
 				perror("setsockopt v6 multicast");
6657fd
 	}
6657fd
+	close(s);
6657fd
 #endif
6657fd
-
6657fd
-	/* close(s); */
6657fd
+	freeaddrinfo (res);
6657fd
 }
6657fd
 
6657fd
 struct sockaddr *