summaryrefslogtreecommitdiffstats
path: root/lib/libzfs
diff options
context:
space:
mode:
authorloli10K <[email protected]>2019-07-09 00:10:23 +0200
committerBrian Behlendorf <[email protected]>2019-07-08 15:10:23 -0700
commit1d20b763bb63782bb281173b1b82fe54fefaa624 (patch)
treeb54001998c0c05991bc297fadce290fd46303375 /lib/libzfs
parentf664f1ee7fc9dd7101171f6518c67951cb5bd8cf (diff)
zfs send does not handle invalid input gracefully
Due to some changes introduced in 30af21b 'zfs send' can crash when provided with invalid inputs: this change attempts to add more checks to the affected code paths. Reviewed-by: Attila Fülöp <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #9001
Diffstat (limited to 'lib/libzfs')
-rw-r--r--lib/libzfs/libzfs_sendrecv.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c
index 885f263bf..9fdb99052 100644
--- a/lib/libzfs/libzfs_sendrecv.c
+++ b/lib/libzfs/libzfs_sendrecv.c
@@ -2422,6 +2422,10 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
}
zfs_handle_t *tosnap = zfs_open(zhp->zfs_hdl,
full_tosnap_name, ZFS_TYPE_SNAPSHOT);
+ if (tosnap == NULL) {
+ err = -1;
+ goto err_out;
+ }
err = send_prelim_records(tosnap, fromsnap, outfd,
flags->replicate || flags->props || flags->holds,
flags->replicate, flags->verbosity > 0, flags->dryrun,
@@ -2707,6 +2711,8 @@ zfs_send_one(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags,
if (from != NULL && strchr(from, '@')) {
zfs_handle_t *from_zhp = zfs_open(hdl, from,
ZFS_TYPE_DATASET);
+ if (from_zhp == NULL)
+ return (-1);
if (!snapshot_is_before(from_zhp, zhp)) {
zfs_close(from_zhp);
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,