Blame SOURCES/libtirpc-1.1.4-covscan.patch

32af26
diff --git a/src/auth_gss.c b/src/auth_gss.c
32af26
index 5959893..7d08262 100644
32af26
--- a/src/auth_gss.c
32af26
+++ b/src/auth_gss.c
32af26
@@ -207,6 +207,7 @@ authgss_create(CLIENT *clnt, gss_name_t name, struct rpc_gss_sec *sec)
32af26
 			rpc_createerr.cf_stat = RPC_SYSTEMERROR;
32af26
 			rpc_createerr.cf_error.re_errno = ENOMEM;
32af26
 			free(auth);
32af26
+			free(gd);
32af26
 			return (NULL);
32af26
 		}
32af26
 	}
32af26
@@ -592,7 +593,7 @@ _rpc_gss_refresh(AUTH *auth, rpc_gss_options_ret_t *options_ret)
32af26
 			if (rpc_gss_oid_to_mech(actual_mech_type, &mechanism)) {
32af26
 				strncpy(options_ret->actual_mechanism,
32af26
 					mechanism,
32af26
-					sizeof(options_ret->actual_mechanism));
32af26
+					(sizeof(options_ret->actual_mechanism)-1));
32af26
 			}
32af26
 
32af26
 			gd->established = TRUE;
32af26
diff --git a/src/clnt_bcast.c b/src/clnt_bcast.c
32af26
index 98cf061..2ad6c89 100644
32af26
--- a/src/clnt_bcast.c
32af26
+++ b/src/clnt_bcast.c
32af26
@@ -330,6 +330,7 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp,
32af26
 	if (nettype == NULL)
32af26
 		nettype = "datagram_n";
32af26
 	if ((handle = __rpc_setconf(nettype)) == NULL) {
32af26
+		AUTH_DESTROY(sys_auth);
32af26
 		return (RPC_UNKNOWNPROTO);
32af26
 	}
32af26
 	while ((nconf = __rpc_getconf(handle)) != NULL) {
32af26
diff --git a/src/getnetconfig.c b/src/getnetconfig.c
32af26
index 92e7c43..d67d97d 100644
32af26
--- a/src/getnetconfig.c
32af26
+++ b/src/getnetconfig.c
32af26
@@ -709,6 +709,8 @@ struct netconfig	*ncp;
32af26
     p->nc_lookups = (char **)malloc((size_t)(p->nc_nlookups+1) * sizeof(char *));
32af26
     if (p->nc_lookups == NULL) {
32af26
 	free(p->nc_netid);
32af26
+	free(p);
32af26
+	free(tmp);
32af26
 	return(NULL);
32af26
     }
32af26
     for (i=0; i < p->nc_nlookups; i++) {
32af26
diff --git a/src/getnetpath.c b/src/getnetpath.c
32af26
index 7c19932..ea1a18c 100644
32af26
--- a/src/getnetpath.c
32af26
+++ b/src/getnetpath.c
32af26
@@ -88,6 +88,7 @@ setnetpath()
32af26
     }
32af26
     if ((np_sessionp->nc_handlep = setnetconfig()) == NULL) {
32af26
 	syslog (LOG_ERR, "rpc: failed to open " NETCONFIG);
32af26
+	free(np_sessionp);
32af26
 	return (NULL);
32af26
     }
32af26
     np_sessionp->valid = NP_VALID;
32af26
diff --git a/src/rpc_generic.c b/src/rpc_generic.c
32af26
index 589cbd5..51f36ac 100644
32af26
--- a/src/rpc_generic.c
32af26
+++ b/src/rpc_generic.c
32af26
@@ -319,6 +319,7 @@ __rpc_setconf(nettype)
32af26
 		handle->nflag = FALSE;
32af26
 		break;
32af26
 	default:
32af26
+		free(handle);
32af26
 		return (NULL);
32af26
 	}
32af26
 
32af26
diff --git a/src/rpc_soc.c b/src/rpc_soc.c
32af26
index 5a6eeb7..a85cb17 100644
32af26
--- a/src/rpc_soc.c
32af26
+++ b/src/rpc_soc.c
32af26
@@ -663,15 +663,17 @@ svcunix_create(sock, sendsize, recvsize, path)
32af26
 		    strcmp(nconf->nc_protofmly, NC_LOOPBACK) == 0)
32af26
 			break;
32af26
 	}
32af26
-	if (nconf == NULL)
32af26
+	if (nconf == NULL) {
32af26
+		endnetconfig(localhandle);
32af26
 		return(xprt);
32af26
+	}
32af26
 
32af26
 	if ((sock = __rpc_nconf2fd(nconf)) < 0)
32af26
 		goto done;
32af26
 
32af26
 	memset(&sun, 0, sizeof sun);
32af26
 	sun.sun_family = AF_LOCAL;
32af26
-	strncpy(sun.sun_path, path, sizeof(sun.sun_path));
32af26
+	strncpy(sun.sun_path, path, (sizeof(sun.sun_path)-1));
32af26
 	addrlen = sizeof(struct sockaddr_un);
32af26
 	sa = (struct sockaddr *)&sun;
32af26
 
32af26
@@ -692,6 +694,8 @@ svcunix_create(sock, sendsize, recvsize, path)
32af26
 	}
32af26
 
32af26
 	xprt = (SVCXPRT *)svc_tli_create(sock, nconf, &taddr, sendsize, recvsize);
32af26
+	if (xprt == NULL)
32af26
+		close(sock);
32af26
 
32af26
 done:
32af26
 	endnetconfig(localhandle);
32af26
diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c
32af26
index e45736a..0c34cb7 100644
32af26
--- a/src/rpcb_clnt.c
32af26
+++ b/src/rpcb_clnt.c
32af26
@@ -547,6 +547,7 @@ try_nconf:
32af26
 		if (tmpnconf == NULL) {
32af26
  			rpc_createerr.cf_stat = RPC_UNKNOWNPROTO;
32af26
 			mutex_unlock(&loopnconf_lock);
32af26
+			endnetconfig(nc_handle);
32af26
 			return (NULL);
32af26
 		}
32af26
 		loopnconf = getnetconfigent(tmpnconf->nc_netid);
32af26
diff --git a/src/rtime.c b/src/rtime.c
32af26
index b642840..29fbf0a 100644
32af26
--- a/src/rtime.c
32af26
+++ b/src/rtime.c
32af26
@@ -90,6 +90,7 @@ rtime(addrp, timep, timeout)
32af26
 
32af26
 	/* TCP and UDP port are the same in this case */
32af26
 	if ((serv = getservbyname("time", "tcp")) == NULL) {
32af26
+		do_close(s);
32af26
 		return(-1);
32af26
 	}
32af26
 
32af26
diff --git a/src/svc_generic.c b/src/svc_generic.c
32af26
index 52a56c2..20abaa2 100644
32af26
--- a/src/svc_generic.c
32af26
+++ b/src/svc_generic.c
32af26
@@ -113,6 +113,7 @@ svc_create(dispatch, prognum, versnum, nettype)
32af26
 				if (l == NULL) {
32af26
 					warnx("svc_create: no memory");
32af26
 					mutex_unlock(&xprtlist_lock);
32af26
+					__rpc_endconf(handle);
32af26
 					return (0);
32af26
 				}
32af26
 				l->xprt = xprt;
32af26
diff --git a/src/svc_simple.c b/src/svc_simple.c
32af26
index cb58002..c32fe0a 100644
32af26
--- a/src/svc_simple.c
32af26
+++ b/src/svc_simple.c
32af26
@@ -157,6 +157,7 @@ rpc_reg(prognum, versnum, procnum, progname, inproc, outproc, nettype)
32af26
 				((netid = strdup(nconf->nc_netid)) == NULL)) {
32af26
 				warnx(rpc_reg_err, rpc_reg_msg, __no_mem_str);
32af26
 				SVC_DESTROY(svcxprt);
32af26
+				free(xdrbuf);
32af26
 				break;
32af26
 			}
32af26
 			madenow = TRUE;