All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alice Mitchell <ajmitchell@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: steved@redhat.com, Alice Mitchell <ajmitchell@redhat.com>
Subject: [PATCH 1/4 v2] nfs-utils: Fix potential memory leaks in idmap
Date: Thu, 12 Aug 2021 19:13:16 +0100	[thread overview]
Message-ID: <20210812181319.3885781-2-ajmitchell@redhat.com> (raw)
In-Reply-To: <20210812181319.3885781-1-ajmitchell@redhat.com>

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 <ajmitchell@redhat.com>
---
 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


  reply	other threads:[~2021-08-12 18:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 18:13 [PATCH 0/4 v2] nfs-utils: A series of memory fixes Alice Mitchell
2021-08-12 18:13 ` Alice Mitchell [this message]
2021-08-12 18:13 ` [PATCH 2/4 v2] nfs-utils: Fix mem leaks in gssd Alice Mitchell
2021-08-12 18:13 ` [PATCH 3/4 v2] nfs-utils: Fix mem leaks in krb5_util Alice Mitchell
2021-08-12 18:13 ` [PATCH 4/4 v2] nfs-utils: Fix mem leak in mountd Alice Mitchell
2021-08-26 19:21 ` [PATCH 0/4 v2] nfs-utils: A series of memory fixes Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210812181319.3885781-2-ajmitchell@redhat.com \
    --to=ajmitchell@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.