Blame SOURCES/libtirpc-1.1.4-dup_ncp-bad-free.patch

32af26
commit 959b2001458bca8f9228014371aad6ccbeb95a68
32af26
Author: Zhi Li <yieli@redhat.com>
32af26
Date:   Wed Sep 26 14:05:29 2018 -0400
32af26
32af26
    getnetconfig.c: fix a BAD_FREE (CWE-763)
32af26
    
32af26
    Signed-off-by: Steve Dickson <steved@redhat.com>
32af26
32af26
diff --git a/src/getnetconfig.c b/src/getnetconfig.c
32af26
index d67d97d..cfd33c2 100644
32af26
--- a/src/getnetconfig.c
32af26
+++ b/src/getnetconfig.c
32af26
@@ -681,6 +681,7 @@ struct netconfig	*ncp;
32af26
 {
32af26
     struct netconfig	*p;
32af26
     char	*tmp;
32af26
+    char	*t;
32af26
     u_int	i;
32af26
 
32af26
     if ((tmp=malloc(MAXNETCONFIGLINE)) == NULL)
32af26
@@ -700,22 +701,21 @@ struct netconfig	*ncp;
32af26
      */
32af26
     *p = *ncp;
32af26
     p->nc_netid = (char *)strcpy(tmp,ncp->nc_netid);
32af26
-    tmp = strchr(tmp, 0) + 1;
32af26
-    p->nc_protofmly = (char *)strcpy(tmp,ncp->nc_protofmly);
32af26
-    tmp = strchr(tmp, 0) + 1;
32af26
-    p->nc_proto = (char *)strcpy(tmp,ncp->nc_proto);
32af26
-    tmp = strchr(tmp, 0) + 1;
32af26
-    p->nc_device = (char *)strcpy(tmp,ncp->nc_device);
32af26
+    t = strchr(tmp, 0) + 1;
32af26
+    p->nc_protofmly = (char *)strcpy(t,ncp->nc_protofmly);
32af26
+    t = strchr(t, 0) + 1;
32af26
+    p->nc_proto = (char *)strcpy(t,ncp->nc_proto);
32af26
+    t = strchr(t, 0) + 1;
32af26
+    p->nc_device = (char *)strcpy(t,ncp->nc_device);
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
-    	tmp = strchr(tmp, 0) + 1;
32af26
-    	p->nc_lookups[i] = (char *)strcpy(tmp,ncp->nc_lookups[i]);
32af26
+	t = strchr(t, 0) + 1;
32af26
+	p->nc_lookups[i] = (char *)strcpy(t,ncp->nc_lookups[i]);
32af26
     }
32af26
     return(p);
32af26
 }