From 8c98c47f9b147a77bfca7cc75b97cc0e98e4551e Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sun, 21 Apr 2019 02:50:29 -0500 Subject: user/nfs-utils: fix freeaddrinfo(3) usage --- user/nfs-utils/freeaddrinfo-properly.patch | 126 +++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 user/nfs-utils/freeaddrinfo-properly.patch (limited to 'user/nfs-utils/freeaddrinfo-properly.patch') diff --git a/user/nfs-utils/freeaddrinfo-properly.patch b/user/nfs-utils/freeaddrinfo-properly.patch new file mode 100644 index 000000000..7ddcde004 --- /dev/null +++ b/user/nfs-utils/freeaddrinfo-properly.patch @@ -0,0 +1,126 @@ +diff -Naur nfs-utils-2.3.3-orig/support/export/client.c nfs-utils-2.3.3/support/export/client.c +--- nfs-utils-2.3.3-orig/support/export/client.c 2018-09-06 13:09:08.000000000 -0500 ++++ nfs-utils-2.3.3/support/export/client.c 2019-04-21 02:48:45.676838188 -0500 +@@ -309,7 +309,8 @@ + init_addrlist(clp, ai); + + out: +- freeaddrinfo(ai); ++ if (ai != NULL) ++ freeaddrinfo(ai); + return clp; + } + +diff -Naur nfs-utils-2.3.3-orig/tests/nsm_client/nsm_client.c nfs-utils-2.3.3/tests/nsm_client/nsm_client.c +--- nfs-utils-2.3.3-orig/tests/nsm_client/nsm_client.c 2018-09-06 13:09:08.000000000 -0500 ++++ nfs-utils-2.3.3/tests/nsm_client/nsm_client.c 2019-04-21 02:35:53.139552780 -0500 +@@ -243,7 +243,8 @@ + printf("RPC client creation failed\n"); + } + out: +- freeaddrinfo(ai); ++ if (ai != NULL) ++ freeaddrinfo(ai); + return client; + } + +diff -Naur nfs-utils-2.3.3-orig/utils/exportfs/exportfs.c nfs-utils-2.3.3/utils/exportfs/exportfs.c +--- nfs-utils-2.3.3-orig/utils/exportfs/exportfs.c 2018-09-06 13:09:08.000000000 -0500 ++++ nfs-utils-2.3.3/utils/exportfs/exportfs.c 2019-04-21 02:40:07.432327005 -0500 +@@ -282,7 +282,8 @@ + validate_export(exp); + + out: +- freeaddrinfo(ai); ++ if (ai != NULL) ++ freeaddrinfo(ai); + } + + static int exportfs_generic(char *arg, char *options, int verbose) +@@ -395,7 +396,8 @@ + if (!success) + xlog(L_ERROR, "Could not find '%s:%s' to unexport.", hname, path); + +- freeaddrinfo(ai); ++ if (ai != NULL) ++ freeaddrinfo(ai); + } + + static int unexportfs_generic(char *arg, int verbose) +@@ -639,8 +641,10 @@ + } + + out: +- freeaddrinfo(results1); +- freeaddrinfo(results2); ++ if (results1 != NULL) ++ freeaddrinfo(results1); ++ if (results2 != NULL) ++ freeaddrinfo(results2); + return result; + } + +diff -Naur nfs-utils-2.3.3-orig/utils/mount/stropts.c nfs-utils-2.3.3/utils/mount/stropts.c +--- nfs-utils-2.3.3-orig/utils/mount/stropts.c 2018-09-06 13:09:08.000000000 -0500 ++++ nfs-utils-2.3.3/utils/mount/stropts.c 2019-04-21 02:43:18.451874403 -0500 +@@ -1263,7 +1263,8 @@ + } else + nfs_error(_("%s: internal option parsing error"), progname); + +- freeaddrinfo(mi.address); ++ if (mi.address != NULL) ++ freeaddrinfo(mi.address); + free(mi.hostname); + return retval; + } +diff -Naur nfs-utils-2.3.3-orig/utils/mountd/cache.c nfs-utils-2.3.3/utils/mountd/cache.c +--- nfs-utils-2.3.3-orig/utils/mountd/cache.c 2019-04-21 02:33:43.603417171 -0500 ++++ nfs-utils-2.3.3/utils/mountd/cache.c 2019-04-21 02:45:11.289792765 -0500 +@@ -834,7 +834,8 @@ + out: + if (found_path) + free(found_path); +- freeaddrinfo(ai); ++ if (ai != NULL) ++ freeaddrinfo(ai); + free(dom); + xlog(D_CALL, "nfsd_fh: found %p path %s", found, found ? found->e_path : NULL); + } +@@ -1355,7 +1356,7 @@ + xlog(D_CALL, "nfsd_export: found %p path %s", found, path ? path : NULL); + if (dom) free(dom); + if (path) free(path); +- freeaddrinfo(ai); ++ if (ai) freeaddrinfo(ai); + } + + +diff -Naur nfs-utils-2.3.3-orig/utils/mountd/mountd.c nfs-utils-2.3.3/utils/mountd/mountd.c +--- nfs-utils-2.3.3-orig/utils/mountd/mountd.c 2018-09-06 13:09:08.000000000 -0500 ++++ nfs-utils-2.3.3/utils/mountd/mountd.c 2019-04-21 02:45:41.796526387 -0500 +@@ -581,7 +581,8 @@ + freeaddrinfo(ai); + continue; + } +- freeaddrinfo(ai); ++ if (ai != NULL) ++ freeaddrinfo(ai); + } + cp = &(c->gr_next); + } +diff -Naur nfs-utils-2.3.3-orig/utils/statd/hostname.c nfs-utils-2.3.3/utils/statd/hostname.c +--- nfs-utils-2.3.3-orig/utils/statd/hostname.c 2018-09-06 13:09:08.000000000 -0500 ++++ nfs-utils-2.3.3/utils/statd/hostname.c 2019-04-21 02:41:39.712446505 -0500 +@@ -308,8 +308,10 @@ + } + + out: +- freeaddrinfo(results2); +- freeaddrinfo(results1); ++ if (results2 != NULL) ++ freeaddrinfo(results2); ++ if (results1 != NULL) ++ freeaddrinfo(results1); + + xlog(D_CALL, "%s: hostnames %s and %s %s", __func__, + hostname1, hostname2, -- cgit v1.2.3-60-g2f50