diff mbox series

[PATCH-V2,libtirpc] getnetconfig.c: fix a BAD_FREE (CWE-763)

Message ID 1537932352-19537-1-git-send-email-yieli@redhat.com (mailing list archive)
State New, archived
Headers show
Series [PATCH-V2,libtirpc] getnetconfig.c: fix a BAD_FREE (CWE-763) | expand

Commit Message

Zhi Li Sept. 26, 2018, 3:25 a.m. UTC
Signed-off-by: Zhi Li <yieli@redhat.com>
---
From steved:
Ok... I see why tmp original value needs to be maintained
to do the free()... but I'm wondering why the freeing
of p->nc_netid is needed... it appears to me it is part
of tmp string... so when tmp is freed won't p->nc_netid
be freed as well?

Reply:
Yes,you are right, p->nc_neti is a part of tmp string, so freeing tmp can make p->nc_neti be freed as well.
p->nc_neti and tmp point to the same block of memory, so I only need to free p->nc_neti.
I have update the issue.

 src/getnetconfig.c | 1 -
 1 file changed, 1 deletion(-)
diff mbox series

Patch

diff --git a/src/getnetconfig.c b/src/getnetconfig.c
index d67d97d..11b2449 100644
--- a/src/getnetconfig.c
+++ b/src/getnetconfig.c
@@ -710,7 +710,6 @@  struct netconfig	*ncp;
     if (p->nc_lookups == NULL) {
 	free(p->nc_netid);
 	free(p);
-	free(tmp);
 	return(NULL);
     }
     for (i=0; i < p->nc_nlookups; i++) {