summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAlice Mitchell <ajmitchell@redhat.com>2021-08-21 13:42:33 -0400
committerSteve Dickson <steved@redhat.com>2021-08-21 14:02:56 -0400
commit8d8f2792eb266a42ecf40ed5473af6a24f0d3bdf (patch)
tree45b0da213ca7e3e567fc53325099ca0d98c3710b /utils
parent647f3796d11ed6122d13331b96d15c1151b59e23 (diff)
downloadnfs-utils-8d8f2792eb266a42ecf40ed5473af6a24f0d3bdf.tar.gz
nfs-utils: Fix mem leaks in gssd
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> Signed-off-by: Steve Dickson <steved@redhat.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/gssd/gssd.c10
1 files 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;
}