From: Alice Mitchell <ajmitchell@redhat.com>
To: linux-nfs@vger.kernel.org
Cc: steved@redhat.com, Alice Mitchell <ajmitchell@redhat.com>
Subject: [PATCH 2/4 v2] nfs-utils: Fix mem leaks in gssd
Date: Thu, 12 Aug 2021 19:13:17 +0100 [thread overview]
Message-ID: <20210812181319.3885781-3-ajmitchell@redhat.com> (raw)
In-Reply-To: <20210812181319.3885781-1-ajmitchell@redhat.com>
ccachedir_copy isnt used properly and is leaking, ccachedir gets modified
by a strtok, altering the original argv or conf parameter which is an
undesirable side-effect
Signed-off-by: Alice Mitchell <ajmitchell@redhat.com>
---
utils/gssd/gssd.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/utils/gssd/gssd.c b/utils/gssd/gssd.c
index 4113cba..833d8e0 100644
--- a/utils/gssd/gssd.c
+++ b/utils/gssd/gssd.c
@@ -1016,7 +1016,7 @@ read_gss_conf(void)
keytabfile = s;
s = conf_get_str("gssd", "cred-cache-directory");
if (s)
- ccachedir = s;
+ ccachedir = strdup(s);
s = conf_get_str("gssd", "preferred-realm");
if (s)
preferred_realm = s;
@@ -1070,7 +1070,8 @@ main(int argc, char *argv[])
keytabfile = optarg;
break;
case 'd':
- ccachedir = optarg;
+ free(ccachedir);
+ ccachedir = strdup(optarg);
break;
case 't':
context_timeout = atoi(optarg);
@@ -1133,7 +1134,6 @@ main(int argc, char *argv[])
}
if (ccachedir) {
- char *ccachedir_copy;
char *ptr;
for (ptr = ccachedir, i = 2; *ptr; ptr++)
@@ -1141,8 +1141,7 @@ main(int argc, char *argv[])
i++;
ccachesearch = malloc(i * sizeof(char *));
- ccachedir_copy = strdup(ccachedir);
- if (!ccachedir_copy || !ccachesearch) {
+ if (!ccachesearch) {
printerr(0, "malloc failure\n");
exit(EXIT_FAILURE);
}
@@ -1274,6 +1273,7 @@ main(int argc, char *argv[])
free(preferred_realm);
free(ccachesearch);
+ free(ccachedir);
return rc < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
--
2.27.0
next prev parent 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 ` [PATCH 1/4 v2] nfs-utils: Fix potential memory leaks in idmap Alice Mitchell
2021-08-12 18:13 ` Alice Mitchell [this message]
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-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox