Thread (6 messages) 6 messages, 2 authors, 2021-08-26
STALE1748d
Revisions (2)
  1. v1 [diff vs current]
  2. v2 current

[PATCH 1/4 v2] nfs-utils: Fix potential memory leaks in idmap

From: Alice Mitchell <hidden>
Date: 2021-08-12 18:13:30
Subsystem: the rest · Maintainer: Linus Torvalds

regex.c: regex_getpwnam() would leak memory if the name was not found.

nss.c: nss_name_to_gid() the conditional frees look like a potential
       memory leak, removed the unnecessary conditions.

Signed-off-by: Alice Mitchell <redacted>
---
 support/nfsidmap/nss.c   | 6 ++----
 support/nfsidmap/regex.c | 1 +
 2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/support/nfsidmap/nss.c b/support/nfsidmap/nss.c
index 669760b..0f43076 100644
--- a/support/nfsidmap/nss.c
+++ b/support/nfsidmap/nss.c
@@ -365,10 +365,8 @@ static int _nss_name_to_gid(char *name, gid_t *gid, int dostrip)
 out_buf:
 	free(buf);
 out_name:
-	if (dostrip)
-		free(localname);
-	if (get_reformat_group())
-		free(ref_name);
+	free(localname);
+	free(ref_name);
 out:
 	return err;
 }
diff --git a/support/nfsidmap/regex.c b/support/nfsidmap/regex.c
index fdbb2e2..958b4ac 100644
--- a/support/nfsidmap/regex.c
+++ b/support/nfsidmap/regex.c
@@ -157,6 +157,7 @@ again:
 	IDMAP_LOG(4, ("regexp_getpwnam: name '%s' mapped to '%s'",
 		  name, localname));
 
+	free(localname);
 	*err_p = 0;
 	return pw;
 
-- 
2.27.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help