Blame SOURCES/nfs-utils-2.3.3-covscan-resource-leaks.patch

bc9fd4
diff -up nfs-utils-2.3.3/configure.ac.orig nfs-utils-2.3.3/configure.ac
bc9fd4
--- nfs-utils-2.3.3/configure.ac.orig	2019-09-18 10:57:14.190810677 -0400
bc9fd4
+++ nfs-utils-2.3.3/configure.ac	2019-09-18 10:57:56.715567641 -0400
bc9fd4
@@ -561,6 +561,7 @@ my_am_cflags="\
bc9fd4
  -Werror=parentheses \
bc9fd4
  -Werror=aggregate-return \
bc9fd4
  -Werror=unused-result \
bc9fd4
+ -Wno-cast-function-type \
bc9fd4
  -fno-strict-aliasing \
bc9fd4
 "
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/support/junction/path.c.orig nfs-utils-2.3.3/support/junction/path.c
bc9fd4
--- nfs-utils-2.3.3/support/junction/path.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/support/junction/path.c	2019-09-18 10:57:56.715567641 -0400
bc9fd4
@@ -163,8 +163,10 @@ nsdb_count_components(const char *pathna
bc9fd4
 			break;
bc9fd4
 		next = strchrnul(component, '/');
bc9fd4
 		tmp = (size_t)(next - component);
bc9fd4
-		if (tmp > 255)
bc9fd4
+		if (tmp > 255) {
bc9fd4
+			free(start);
bc9fd4
 			return false;
bc9fd4
+		}
bc9fd4
 		length += XDR_UINT_BYTES + (nsdb_quadlen(tmp) << 2);
bc9fd4
 		count++;
bc9fd4
 
bc9fd4
@@ -328,11 +330,13 @@ nsdb_posix_to_path_array(const char *pat
bc9fd4
 		length = (size_t)(next - component);
bc9fd4
 		if (length > 255) {
bc9fd4
 			nsdb_free_string_array(result);
bc9fd4
+			free(normalized);
bc9fd4
 			return FEDFS_ERR_SVRFAULT;
bc9fd4
 		}
bc9fd4
 
bc9fd4
 		result[i] = strndup(component, length);
bc9fd4
 		if (result[i] == NULL) {
bc9fd4
+			free(normalized);
bc9fd4
 			nsdb_free_string_array(result);
bc9fd4
 			return FEDFS_ERR_SVRFAULT;
bc9fd4
 		}
bc9fd4
diff -up nfs-utils-2.3.3/support/nfs/exports.c.orig nfs-utils-2.3.3/support/nfs/exports.c
bc9fd4
--- nfs-utils-2.3.3/support/nfs/exports.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/support/nfs/exports.c	2019-09-18 10:57:56.715567641 -0400
bc9fd4
@@ -714,6 +714,7 @@ parsesquash(char *list, int **idp, int *
bc9fd4
 		}
bc9fd4
 		if (id0 == -1 || id1 == -1) {
bc9fd4
 			syntaxerr("uid/gid -1 not permitted");
bc9fd4
+			xfree(id);
bc9fd4
 			return -1;
bc9fd4
 		}
bc9fd4
 		if ((len % 8) == 0)
bc9fd4
@@ -724,6 +725,7 @@ parsesquash(char *list, int **idp, int *
bc9fd4
 			break;
bc9fd4
 		if (*cp != ',') {
bc9fd4
 			syntaxerr("bad uid/gid list");
bc9fd4
+			xfree(id);
bc9fd4
 			return -1;
bc9fd4
 		}
bc9fd4
 		cp++;
bc9fd4
diff -up nfs-utils-2.3.3/support/nfsidmap/libnfsidmap.c.orig nfs-utils-2.3.3/support/nfsidmap/libnfsidmap.c
bc9fd4
--- nfs-utils-2.3.3/support/nfsidmap/libnfsidmap.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/support/nfsidmap/libnfsidmap.c	2019-09-18 10:57:56.716567635 -0400
bc9fd4
@@ -406,8 +406,10 @@ int nfs4_init_name_mapping(char *conffil
bc9fd4
 	nfs4_methods = conf_get_list("Translation", "Method");
bc9fd4
 	if (nfs4_methods) {
bc9fd4
 		IDMAP_LOG(1, ("libnfsidmap: processing 'Method' list"));
bc9fd4
-		if (load_plugins(nfs4_methods, &nfs4_plugins) == -1)
bc9fd4
+		if (load_plugins(nfs4_methods, &nfs4_plugins) == -1) {
bc9fd4
+			conf_free_list(nfs4_methods);
bc9fd4
 			return -ENOENT;
bc9fd4
+		}
bc9fd4
 	} else {
bc9fd4
 		struct conf_list list;
bc9fd4
 		struct conf_list_node node;
bc9fd4
@@ -475,11 +477,15 @@ out:
bc9fd4
 	if (ret) {
bc9fd4
 		if (nfs4_plugins)
bc9fd4
 			unload_plugins(nfs4_plugins);
bc9fd4
-		if (gss_plugins)
bc9fd4
+		if (gss_plugins) {
bc9fd4
 			unload_plugins(gss_plugins);
bc9fd4
+		}
bc9fd4
 		nfs4_plugins = gss_plugins = NULL;
bc9fd4
 	}
bc9fd4
 
bc9fd4
+	if (gss_methods)
bc9fd4
+		conf_free_list(gss_methods);
bc9fd4
+
bc9fd4
 	return ret ? -ENOENT: 0;
bc9fd4
 }
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/support/nfsidmap/static.c.orig nfs-utils-2.3.3/support/nfsidmap/static.c
bc9fd4
--- nfs-utils-2.3.3/support/nfsidmap/static.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/support/nfsidmap/static.c	2019-09-18 10:57:56.716567635 -0400
bc9fd4
@@ -347,6 +347,7 @@ static int static_init(void) {
bc9fd4
 			warnx("static_init: calloc (1, %lu) failed",
bc9fd4
 				(unsigned long)sizeof *unode);
bc9fd4
 			free(pw);
bc9fd4
+			conf_free_list(princ_list);
bc9fd4
 			return -ENOMEM;
bc9fd4
 		}
bc9fd4
 		unode->uid = pw->pw_uid;
bc9fd4
@@ -355,6 +356,9 @@ static int static_init(void) {
bc9fd4
 		unode->localname = conf_get_str("Static", cln->field);
bc9fd4
 		if (!unode->localname) {
bc9fd4
 			free(pw);
bc9fd4
+			free(unode->principal);
bc9fd4
+			free(unode);
bc9fd4
+			conf_free_list(princ_list);
bc9fd4
 			return -ENOENT;
bc9fd4
 		}
bc9fd4
 
bc9fd4
@@ -379,6 +383,7 @@ static int static_init(void) {
bc9fd4
 			warnx("static_init: calloc (1, %lu) failed",
bc9fd4
 				(unsigned long)sizeof *gnode);
bc9fd4
 			free(gr);
bc9fd4
+			conf_free_list(princ_list);
bc9fd4
 			return -ENOMEM;
bc9fd4
 		}
bc9fd4
 		gnode->gid = gr->gr_gid;
bc9fd4
@@ -387,6 +392,9 @@ static int static_init(void) {
bc9fd4
 		gnode->localgroup = conf_get_str("Static", cln->field);
bc9fd4
 		if (!gnode->localgroup) {
bc9fd4
 			free(gr);
bc9fd4
+			free(gnode->principal);
bc9fd4
+			free(gnode);
bc9fd4
+			conf_free_list(princ_list);
bc9fd4
 			return -ENOENT;
bc9fd4
 		}
bc9fd4
 
bc9fd4
@@ -394,6 +402,8 @@ static int static_init(void) {
bc9fd4
 
bc9fd4
 		LIST_INSERT_HEAD (&gid_mappings[gid_hash(gnode->gid)], gnode, link);
bc9fd4
 	}
bc9fd4
+	
bc9fd4
+	conf_free_list(princ_list);
bc9fd4
 	return 0;
bc9fd4
 }
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/support/nfs/mydaemon.c.orig nfs-utils-2.3.3/support/nfs/mydaemon.c
bc9fd4
--- nfs-utils-2.3.3/support/nfs/mydaemon.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/support/nfs/mydaemon.c	2019-09-18 10:57:56.716567635 -0400
bc9fd4
@@ -123,6 +123,7 @@ daemon_init(bool fg)
bc9fd4
 	dup2(tempfd, 0);
bc9fd4
 	dup2(tempfd, 1);
bc9fd4
 	dup2(tempfd, 2);
bc9fd4
+	close(tempfd);
bc9fd4
 	closelog();
bc9fd4
 	dup2(pipefds[1], 3);
bc9fd4
 	pipefds[1] = 3;
bc9fd4
diff -up nfs-utils-2.3.3/support/nfs/rpcmisc.c.orig nfs-utils-2.3.3/support/nfs/rpcmisc.c
bc9fd4
--- nfs-utils-2.3.3/support/nfs/rpcmisc.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/support/nfs/rpcmisc.c	2019-09-18 10:57:56.716567635 -0400
bc9fd4
@@ -102,6 +102,7 @@ makesock(int port, int proto)
bc9fd4
 	if (bind(sock, (struct sockaddr *) &sin, sizeof(sin)) == -1) {
bc9fd4
 		xlog(L_FATAL, "Could not bind name to socket: %s",
bc9fd4
 					strerror(errno));
bc9fd4
+		close(sock);
bc9fd4
 		return -1;
bc9fd4
 	}
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/support/nfs/svc_socket.c.orig nfs-utils-2.3.3/support/nfs/svc_socket.c
bc9fd4
--- nfs-utils-2.3.3/support/nfs/svc_socket.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/support/nfs/svc_socket.c	2019-09-18 10:57:56.717567629 -0400
bc9fd4
@@ -134,6 +134,7 @@ svc_socket (u_long number, int type, int
bc9fd4
       if (ret < 0)
bc9fd4
 	{
bc9fd4
 	  xlog(L_ERROR, "svc_socket: socket reuse problem: %m");
bc9fd4
+      (void) __close(sock);
bc9fd4
 	  return ret;
bc9fd4
 	}
bc9fd4
     }
bc9fd4
diff -up nfs-utils-2.3.3/support/nfs/xcommon.c.orig nfs-utils-2.3.3/support/nfs/xcommon.c
bc9fd4
--- nfs-utils-2.3.3/support/nfs/xcommon.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/support/nfs/xcommon.c	2019-09-18 10:57:56.717567629 -0400
bc9fd4
@@ -53,14 +53,17 @@ char *
bc9fd4
 xstrconcat3 (const char *s, const char *t, const char *u) {
bc9fd4
      char *res;
bc9fd4
 
bc9fd4
-     if (!s) s = "";
bc9fd4
+     int dofree = 1;
bc9fd4
+
bc9fd4
+     if (!s) s = "", dofree=0;
bc9fd4
      if (!t) t = "";
bc9fd4
      if (!u) u = "";
bc9fd4
      res = xmalloc(strlen(s) + strlen(t) + strlen(u) + 1);
bc9fd4
      strcpy(res, s);
bc9fd4
      strcat(res, t);
bc9fd4
      strcat(res, u);
bc9fd4
-     free((void *) s);
bc9fd4
+     if (dofree)
bc9fd4
+         free((void *) s);
bc9fd4
      return res;
bc9fd4
 }
bc9fd4
 
bc9fd4
@@ -69,7 +72,9 @@ char *
bc9fd4
 xstrconcat4 (const char *s, const char *t, const char *u, const char *v) {
bc9fd4
      char *res;
bc9fd4
 
bc9fd4
-     if (!s) s = "";
bc9fd4
+     int dofree = 1;
bc9fd4
+
bc9fd4
+     if (!s) s = "", dofree=0;
bc9fd4
      if (!t) t = "";
bc9fd4
      if (!u) u = "";
bc9fd4
      if (!v) v = "";
bc9fd4
@@ -78,7 +83,8 @@ xstrconcat4 (const char *s, const char *
bc9fd4
      strcat(res, t);
bc9fd4
      strcat(res, u);
bc9fd4
      strcat(res, v);
bc9fd4
-     free((void *) s);
bc9fd4
+     if (dofree)
bc9fd4
+         free((void *) s);
bc9fd4
      return res;
bc9fd4
 }
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/support/nfs/xlog.c.orig nfs-utils-2.3.3/support/nfs/xlog.c
bc9fd4
--- nfs-utils-2.3.3/support/nfs/xlog.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/support/nfs/xlog.c	2019-09-18 10:57:56.717567629 -0400
bc9fd4
@@ -135,10 +135,14 @@ xlog_from_conffile(char *service)
bc9fd4
 	struct conf_list_node *n;
bc9fd4
 
bc9fd4
 	kinds = conf_get_list(service, "debug");
bc9fd4
-	if (!kinds || !kinds->cnt)
bc9fd4
+	if (!kinds || !kinds->cnt) {
bc9fd4
+		free(kinds);
bc9fd4
 		return;
bc9fd4
+	}
bc9fd4
 	TAILQ_FOREACH(n, &(kinds->fields), link)
bc9fd4
 		xlog_sconfig(n->field, 1);
bc9fd4
+
bc9fd4
+	conf_free_list(kinds);
bc9fd4
 }
bc9fd4
 
bc9fd4
 int
bc9fd4
diff -up nfs-utils-2.3.3/support/nsm/file.c.orig nfs-utils-2.3.3/support/nsm/file.c
bc9fd4
--- nfs-utils-2.3.3/support/nsm/file.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/support/nsm/file.c	2019-09-18 10:57:56.717567629 -0400
bc9fd4
@@ -533,6 +533,7 @@ nsm_update_kernel_state(const int state)
bc9fd4
 	len = snprintf(buf, sizeof(buf), "%d", state);
bc9fd4
 	if (error_check(len, sizeof(buf))) {
bc9fd4
 		xlog_warn("Failed to form NSM state number string");
bc9fd4
+		close(fd);
bc9fd4
 		return;
bc9fd4
 	}
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/systemd/rpc-pipefs-generator.c.orig nfs-utils-2.3.3/systemd/rpc-pipefs-generator.c
bc9fd4
--- nfs-utils-2.3.3/systemd/rpc-pipefs-generator.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/systemd/rpc-pipefs-generator.c	2019-09-18 10:57:56.717567629 -0400
bc9fd4
@@ -69,12 +69,16 @@ int generate_target(char *pipefs_path, c
bc9fd4
 		return 1;
bc9fd4
 
bc9fd4
 	ret = generate_mount_unit(pipefs_path, pipefs_unit, dirname);
bc9fd4
-	if (ret)
bc9fd4
+	if (ret) {
bc9fd4
+		free(pipefs_unit);
bc9fd4
 		return ret;
bc9fd4
+	}
bc9fd4
 
bc9fd4
 	path = malloc(strlen(dirname) + 1 + sizeof(filebase));
bc9fd4
-	if (!path)
bc9fd4
+	if (!path) {
bc9fd4
+		free(pipefs_unit);
bc9fd4
 		return 2;
bc9fd4
+	}
bc9fd4
 	sprintf(path, "%s", dirname);
bc9fd4
 	mkdir(path, 0755);
bc9fd4
 	strcat(path, filebase);
bc9fd4
@@ -82,6 +86,7 @@ int generate_target(char *pipefs_path, c
bc9fd4
 	if (!f)
bc9fd4
 	{
bc9fd4
 		free(path);
bc9fd4
+		free(pipefs_unit);
bc9fd4
 		return 1;
bc9fd4
 	}
bc9fd4
 
bc9fd4
@@ -90,6 +95,7 @@ int generate_target(char *pipefs_path, c
bc9fd4
 	fprintf(f, "After=%s\n", pipefs_unit);
bc9fd4
 	fclose(f);
bc9fd4
 	free(path);
bc9fd4
+	free(pipefs_unit);
bc9fd4
 
bc9fd4
 	return 0;
bc9fd4
 }
bc9fd4
diff -up nfs-utils-2.3.3/utils/blkmapd/device-discovery.c.orig nfs-utils-2.3.3/utils/blkmapd/device-discovery.c
bc9fd4
--- nfs-utils-2.3.3/utils/blkmapd/device-discovery.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/utils/blkmapd/device-discovery.c	2019-09-18 10:58:54.444237714 -0400
bc9fd4
@@ -186,8 +186,11 @@ static void bl_add_disk(char *filepath)
bc9fd4
 		}
bc9fd4
 	}
bc9fd4
 
bc9fd4
-	if (disk && diskpath)
bc9fd4
+	if (disk && diskpath) {
bc9fd4
+		if (serial)
bc9fd4
+			free(serial);
bc9fd4
 		return;
bc9fd4
+	}
bc9fd4
 
bc9fd4
 	/* add path */
bc9fd4
 	path = malloc(sizeof(struct bl_disk_path));
bc9fd4
@@ -223,6 +226,8 @@ static void bl_add_disk(char *filepath)
bc9fd4
 			disk->size = size;
bc9fd4
 			disk->valid_path = path;
bc9fd4
 		}
bc9fd4
+		if (serial)
bc9fd4
+			free(serial);
bc9fd4
 	}
bc9fd4
 	return;
bc9fd4
 
bc9fd4
@@ -232,6 +237,9 @@ static void bl_add_disk(char *filepath)
bc9fd4
 			free(path->full_path);
bc9fd4
 		free(path);
bc9fd4
 	}
bc9fd4
+	if (serial)
bc9fd4
+		free(serial);
bc9fd4
+
bc9fd4
 	return;
bc9fd4
 }
bc9fd4
 
bc9fd4
@@ -375,7 +383,12 @@ static void bl_rpcpipe_cb(void)
bc9fd4
 			if (event->mask & IN_CREATE) {
bc9fd4
 				BL_LOG_WARNING("nfs pipe dir created\n");
bc9fd4
 				bl_watch_dir(nfspipe_dir, &nfs_pipedir_wfd);
bc9fd4
+				if (bl_pipe_fd >= 0)
bc9fd4
+					close(bl_pipe_fd);
bc9fd4
 				bl_pipe_fd = open(bl_pipe_file, O_RDWR);
bc9fd4
+				if (bl_pipe_fd < 0)
bc9fd4
+					BL_LOG_ERR("open %s failed: %s\n",
bc9fd4
+						event->name, strerror(errno));
bc9fd4
 			} else if (event->mask & IN_DELETE) {
bc9fd4
 				BL_LOG_WARNING("nfs pipe dir deleted\n");
bc9fd4
 				inotify_rm_watch(bl_watch_fd, nfs_pipedir_wfd);
bc9fd4
@@ -388,6 +401,8 @@ static void bl_rpcpipe_cb(void)
bc9fd4
 				continue;
bc9fd4
 			if (event->mask & IN_CREATE) {
bc9fd4
 				BL_LOG_WARNING("blocklayout pipe file created\n");
bc9fd4
+				if (bl_pipe_fd >= 0)
bc9fd4
+					close(bl_pipe_fd);
bc9fd4
 				bl_pipe_fd = open(bl_pipe_file, O_RDWR);
bc9fd4
 				if (bl_pipe_fd < 0)
bc9fd4
 					BL_LOG_ERR("open %s failed: %s\n",
bc9fd4
diff -up nfs-utils-2.3.3/utils/gssd/krb5_util.c.orig nfs-utils-2.3.3/utils/gssd/krb5_util.c
bc9fd4
--- nfs-utils-2.3.3/utils/gssd/krb5_util.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/utils/gssd/krb5_util.c	2019-09-18 10:57:56.718567624 -0400
bc9fd4
@@ -698,6 +698,8 @@ gssd_search_krb5_keytab(krb5_context con
bc9fd4
 				 "we failed to unparse principal name: %s\n",
bc9fd4
 				 k5err);
bc9fd4
 			k5_free_kt_entry(context, kte);
bc9fd4
+			free(k5err);
bc9fd4
+			k5err = NULL;
bc9fd4
 			continue;
bc9fd4
 		}
bc9fd4
 		printerr(4, "Processing keytab entry for principal '%s'\n",
bc9fd4
@@ -899,6 +901,8 @@ find_keytab_entry(krb5_context context,
bc9fd4
 				k5err = gssd_k5_err_msg(context, code);
bc9fd4
 				printerr(1, "%s while building principal for '%s'\n",
bc9fd4
 					 k5err, spn);
bc9fd4
+				free(k5err);
bc9fd4
+				k5err = NULL;
bc9fd4
 				continue;
bc9fd4
 			}
bc9fd4
 			code = krb5_kt_get_entry(context, kt, princ, 0, 0, kte);
bc9fd4
@@ -1168,7 +1172,8 @@ gssd_get_krb5_machine_cred_list(char ***
bc9fd4
 		*list = l;
bc9fd4
 		retval = 0;
bc9fd4
 		goto out;
bc9fd4
-	}
bc9fd4
+	} else
bc9fd4
+		free((void *)l);
bc9fd4
   out:
bc9fd4
 	return retval;
bc9fd4
 }
bc9fd4
@@ -1216,6 +1221,8 @@ gssd_destroy_krb5_machine_creds(void)
bc9fd4
 			printerr(0, "WARNING: %s while resolving credential "
bc9fd4
 				    "cache '%s' for destruction\n", k5err,
bc9fd4
 				    ple->ccname);
bc9fd4
+			free(k5err);
bc9fd4
+			k5err = NULL;
bc9fd4
 			continue;
bc9fd4
 		}
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/utils/mount/configfile.c.orig nfs-utils-2.3.3/utils/mount/configfile.c
bc9fd4
--- nfs-utils-2.3.3/utils/mount/configfile.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/utils/mount/configfile.c	2019-09-18 10:57:56.718567624 -0400
bc9fd4
@@ -404,7 +404,7 @@ char *conf_get_mntopts(char *spec, char
bc9fd4
 
bc9fd4
 	/* list_size + optlen + ',' + '\0' */
bc9fd4
 	config_opts = calloc(1, (list_size+optlen+2));
bc9fd4
-	if (server == NULL) {
bc9fd4
+	if (config_opts == NULL) {
bc9fd4
 		xlog_warn("conf_get_mountops: Unable calloc memory for config_opts"); 
bc9fd4
 		free_all();
bc9fd4
 		return mount_opts;
bc9fd4
diff -up nfs-utils-2.3.3/utils/mountd/cache.c.orig nfs-utils-2.3.3/utils/mountd/cache.c
bc9fd4
--- nfs-utils-2.3.3/utils/mountd/cache.c.orig	2019-09-18 10:57:14.190810677 -0400
bc9fd4
+++ nfs-utils-2.3.3/utils/mountd/cache.c	2019-09-18 10:57:56.718567624 -0400
bc9fd4
@@ -1240,7 +1240,7 @@ static struct exportent *lookup_junction
bc9fd4
 		goto out;
bc9fd4
 	}
bc9fd4
 	status = nfs_get_basic_junction(pathname, &locations);
bc9fd4
-	switch (status) {
bc9fd4
+	if (status) {
bc9fd4
 		xlog(L_WARNING, "Dangling junction %s: %s",
bc9fd4
 			pathname, strerror(status));
bc9fd4
 		goto out;
bc9fd4
@@ -1248,10 +1248,11 @@ static struct exportent *lookup_junction
bc9fd4
 
bc9fd4
 	parent = lookup_parent_export(dom, pathname, ai);
bc9fd4
 	if (parent == NULL)
bc9fd4
-		goto out;
bc9fd4
+		goto free_locations;
bc9fd4
 
bc9fd4
 	exp = locations_to_export(locations, pathname, parent);
bc9fd4
 
bc9fd4
+free_locations:
bc9fd4
 	nfs_free_locations(locations->ns_list);
bc9fd4
 	free(locations);
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/utils/mountd/fsloc.c.orig nfs-utils-2.3.3/utils/mountd/fsloc.c
bc9fd4
--- nfs-utils-2.3.3/utils/mountd/fsloc.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/utils/mountd/fsloc.c	2019-09-18 10:57:56.719567618 -0400
bc9fd4
@@ -102,6 +102,7 @@ static struct servers *parse_list(char *
bc9fd4
 		cp = strchr(list[i], '@');
bc9fd4
 		if ((!cp) || list[i][0] != '/') {
bc9fd4
 			xlog(L_WARNING, "invalid entry '%s'", list[i]);
bc9fd4
+			free(mp);
bc9fd4
 			continue; /* XXX Need better error handling */
bc9fd4
 		}
bc9fd4
 		res->h_mp[i] = mp;
bc9fd4
diff -up nfs-utils-2.3.3/utils/mount/nfsmount.c.orig nfs-utils-2.3.3/utils/mount/nfsmount.c
bc9fd4
--- nfs-utils-2.3.3/utils/mount/nfsmount.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/utils/mount/nfsmount.c	2019-09-18 10:57:56.730567555 -0400
bc9fd4
@@ -452,6 +452,7 @@ parse_options(char *old_opts, struct nfs
bc9fd4
 	nfs_error(_("%s: Bad nfs mount parameter: %s\n"), progname, opt);
bc9fd4
  out_bad:
bc9fd4
 	free(tmp_opts);
bc9fd4
+	free(mounthost);
bc9fd4
 	return 0;
bc9fd4
 }
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/utils/mount/stropts.c.orig nfs-utils-2.3.3/utils/mount/stropts.c
bc9fd4
--- nfs-utils-2.3.3/utils/mount/stropts.c.orig	2019-09-18 10:57:14.183810717 -0400
bc9fd4
+++ nfs-utils-2.3.3/utils/mount/stropts.c	2019-09-18 10:57:56.730567555 -0400
bc9fd4
@@ -982,8 +982,11 @@ static int nfs_try_mount(struct nfsmount
bc9fd4
 		}
bc9fd4
 
bc9fd4
 		if (!nfs_append_addr_option(address->ai_addr,
bc9fd4
-					    address->ai_addrlen, mi->options))
bc9fd4
+					    address->ai_addrlen, mi->options)) {
bc9fd4
+			freeaddrinfo(address);
bc9fd4
+			errno = ENOMEM;
bc9fd4
 			return 0;
bc9fd4
+		}
bc9fd4
 		mi->address = address;
bc9fd4
 	}
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/utils/nfsdcltrack/sqlite.c.orig nfs-utils-2.3.3/utils/nfsdcltrack/sqlite.c
bc9fd4
--- nfs-utils-2.3.3/utils/nfsdcltrack/sqlite.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/utils/nfsdcltrack/sqlite.c	2019-09-18 10:57:56.731567549 -0400
bc9fd4
@@ -215,6 +215,8 @@ sqlite_maindb_init_v2(void)
bc9fd4
 				&err;;
bc9fd4
 	if (ret != SQLITE_OK) {
bc9fd4
 		xlog(L_ERROR, "Unable to begin transaction: %s", err);
bc9fd4
+		if (err)
bc9fd4
+			sqlite3_free(err);
bc9fd4
 		return ret;
bc9fd4
 	}
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/support/nfsidmap/libnfsidmap.c.orig nfs-utils-2.3.3/support/nfsidmap/libnfsidmap.c
bc9fd4
--- nfs-utils-2.3.3/support/nfsidmap/libnfsidmap.c.orig	2019-11-11 08:49:06.044870974 -0500
bc9fd4
+++ nfs-utils-2.3.3/support/nfsidmap/libnfsidmap.c	2019-11-11 09:19:10.391896845 -0500
bc9fd4
@@ -486,6 +486,9 @@ out:
bc9fd4
 	if (gss_methods)
bc9fd4
 		conf_free_list(gss_methods);
bc9fd4
 
bc9fd4
+	if (nfs4_methods)
bc9fd4
+		conf_free_list(nfs4_methods);
bc9fd4
+
bc9fd4
 	return ret ? -ENOENT: 0;
bc9fd4
 }
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/utils/gssd/krb5_util.c.orig nfs-utils-2.3.3/utils/gssd/krb5_util.c
bc9fd4
--- nfs-utils-2.3.3/utils/gssd/krb5_util.c.orig	2019-11-11 08:49:06.045870979 -0500
bc9fd4
+++ nfs-utils-2.3.3/utils/gssd/krb5_util.c	2019-11-11 09:19:10.393896856 -0500
bc9fd4
@@ -911,6 +911,8 @@ find_keytab_entry(krb5_context context,
bc9fd4
 				k5err = gssd_k5_err_msg(context, code);
bc9fd4
 				printerr(3, "%s while getting keytab entry for '%s'\n",
bc9fd4
 					 k5err, spn);
bc9fd4
+				free(k5err);
bc9fd4
+				k5err = NULL;
bc9fd4
 				/*
bc9fd4
 				 * We tried the active directory machine account
bc9fd4
 				 * with the hostname part as-is and failed...
bc9fd4
@@ -1013,6 +1015,8 @@ query_krb5_ccache(const char* cred_cache
bc9fd4
 	char *str = NULL;
bc9fd4
 	char *princstring;
bc9fd4
 
bc9fd4
+	*ret_princname = *ret_realm = NULL;
bc9fd4
+
bc9fd4
 	ret = krb5_init_context(&context);
bc9fd4
 	if (ret) 
bc9fd4
 		return 0;
bc9fd4
@@ -1047,7 +1051,7 @@ err_princ:
bc9fd4
 	krb5_cc_close(context, ccache);
bc9fd4
 err_cache:
bc9fd4
 	krb5_free_context(context);
bc9fd4
-	return found;
bc9fd4
+	return (*ret_princname && *ret_realm);
bc9fd4
 }
bc9fd4
 
bc9fd4
 /*==========================*/
bc9fd4
@@ -1230,6 +1234,8 @@ gssd_destroy_krb5_machine_creds(void)
bc9fd4
 			k5err = gssd_k5_err_msg(context, code);
bc9fd4
 			printerr(0, "WARNING: %s while destroying credential "
bc9fd4
 				    "cache '%s'\n", k5err, ple->ccname);
bc9fd4
+			free(k5err);
bc9fd4
+			k5err = NULL;
bc9fd4
 		}
bc9fd4
 	}
bc9fd4
 	krb5_free_context(context);
bc9fd4
diff -up nfs-utils-2.3.3/utils/idmapd/idmapd.c.orig nfs-utils-2.3.3/utils/idmapd/idmapd.c
bc9fd4
--- nfs-utils-2.3.3/utils/idmapd/idmapd.c.orig	2019-11-11 08:49:06.029870889 -0500
bc9fd4
+++ nfs-utils-2.3.3/utils/idmapd/idmapd.c	2019-11-11 09:19:10.393896856 -0500
bc9fd4
@@ -517,14 +517,16 @@ static void
bc9fd4
 clntscancb(int UNUSED(fd), short UNUSED(which), void *data)
bc9fd4
 {
bc9fd4
 	struct idmap_clientq *icq = data;
bc9fd4
-	struct idmap_client *ic;
bc9fd4
+	struct idmap_client *ic, *ic_next;
bc9fd4
 
bc9fd4
-	TAILQ_FOREACH(ic, icq, ic_next)
bc9fd4
+	for (ic = TAILQ_FIRST(icq); ic != NULL; ic = ic_next) { 
bc9fd4
+		ic_next = TAILQ_NEXT(ic, ic_next);
bc9fd4
 		if (ic->ic_fd == -1 && nfsopen(ic) == -1) {
bc9fd4
 			close(ic->ic_dirfd);
bc9fd4
 			TAILQ_REMOVE(icq, ic, ic_next);
bc9fd4
 			free(ic);
bc9fd4
 		}
bc9fd4
+	}
bc9fd4
 }
bc9fd4
 
bc9fd4
 static void
bc9fd4
diff -up nfs-utils-2.3.3/utils/statd/monitor.c.orig nfs-utils-2.3.3/utils/statd/monitor.c
bc9fd4
--- nfs-utils-2.3.3/utils/statd/monitor.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/utils/statd/monitor.c	2019-11-11 09:19:10.393896856 -0500
bc9fd4
@@ -66,7 +66,7 @@ sm_mon_1_svc(struct mon *argp, struct sv
bc9fd4
 			*my_name  = argp->mon_id.my_id.my_name;
bc9fd4
 	struct my_id	*id = &argp->mon_id.my_id;
bc9fd4
 	char		*cp;
bc9fd4
-	notify_list	*clnt;
bc9fd4
+	notify_list	*clnt = NULL;
bc9fd4
 	struct sockaddr_in my_addr = {
bc9fd4
 		.sin_family		= AF_INET,
bc9fd4
 		.sin_addr.s_addr	= htonl(INADDR_LOOPBACK),
bc9fd4
@@ -223,6 +224,7 @@ sm_mon_1_svc(struct mon *argp, struct sv
bc9fd4
 
bc9fd4
 failure:
bc9fd4
 	xlog_warn("STAT_FAIL to %s for SM_MON of %s", my_name, mon_name);
bc9fd4
+	free(clnt);
bc9fd4
 	return (&result);
bc9fd4
 }
bc9fd4
 
bc9fd4
@@ -242,6 +244,7 @@ load_one_host(const char *hostname,
bc9fd4
 	clnt->dns_name = strdup(hostname);
bc9fd4
 	if (clnt->dns_name == NULL) {
bc9fd4
 		nlist_free(NULL, clnt);
bc9fd4
+		free(clnt);
bc9fd4
 		return 0;
bc9fd4
 	}
bc9fd4
 
bc9fd4
diff -up nfs-utils-2.3.3/utils/statd/notlist.c.orig nfs-utils-2.3.3/utils/statd/notlist.c
bc9fd4
--- nfs-utils-2.3.3/utils/statd/notlist.c.orig	2018-09-06 14:09:08.000000000 -0400
bc9fd4
+++ nfs-utils-2.3.3/utils/statd/notlist.c	2019-11-11 09:19:10.394896861 -0500
bc9fd4
@@ -210,7 +210,6 @@ nlist_free(notify_list **head, notify_li
bc9fd4
 	if (NL_MON_NAME(entry))
bc9fd4
 		free(NL_MON_NAME(entry));
bc9fd4
 	free(entry->dns_name);
bc9fd4
-	free(entry);
bc9fd4
 }
bc9fd4
 
bc9fd4
 /* 
bc9fd4
@@ -219,8 +218,14 @@ nlist_free(notify_list **head, notify_li
bc9fd4
 void 
bc9fd4
 nlist_kill(notify_list **head)
bc9fd4
 {
bc9fd4
-	while (*head)
bc9fd4
+	notify_list *next;
bc9fd4
+
bc9fd4
+	while (*head) {
bc9fd4
+		next = (*head)->next;
bc9fd4
 		nlist_free(head, *head);
bc9fd4
+		free(*head);
bc9fd4
+		*head = next;
bc9fd4
+	}
bc9fd4
 }
bc9fd4
 
bc9fd4
 /*