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

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