aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAllan Jude <[email protected]>2020-09-18 13:23:29 -0400
committerGitHub <[email protected]>2020-09-18 10:23:29 -0700
commit908d43d0a9f736af62c0f4b179950bb1262dfd7d (patch)
tree1c36b0e79ba19a9adb53ba2471d90d4627be0670 /lib
parent8e82ffba7be213373eb7805cadfb6fe3260f0cdd (diff)
libzfs: Don't leak buf if nvlist is too large
Resolves FreeBSD Coverity defect: CID 1432398: Resource leaks (RESOURCE_LEAK) libzfs: don't leak hdl if there is an error reading env var Resolves FreeBSD Coverity defect: CID 1432395: Resource leaks (RESOURCE_LEAK) Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Allan Jude <[email protected]> Closes #10882
Diffstat (limited to 'lib')
-rw-r--r--lib/libzfs/libzfs_sendrecv.c1
-rw-r--r--lib/libzfs/libzfs_util.c3
2 files changed, 4 insertions, 0 deletions
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c
index b17b105ca..b46a4f122 100644
--- a/lib/libzfs/libzfs_sendrecv.c
+++ b/lib/libzfs/libzfs_sendrecv.c
@@ -2640,6 +2640,7 @@ recv_read_nvlist(libzfs_handle_t *hdl, int fd, int len, nvlist_t **nvp,
if (len > hdl->libzfs_max_nvlist) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN, "nvlist too large"));
+ free(buf);
return (ENOMEM);
}
diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c
index 301c8ddba..651bca297 100644
--- a/lib/libzfs/libzfs_util.c
+++ b/lib/libzfs/libzfs_util.c
@@ -1060,6 +1060,9 @@ libzfs_init(void)
if ((error = zfs_nicestrtonum(hdl, env,
&hdl->libzfs_max_nvlist))) {
errno = error;
+ (void) close(hdl->libzfs_fd);
+ (void) fclose(hdl->libzfs_mnttab);
+ free(hdl);
return (NULL);
}
} else {