summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRich Ercolani <[email protected]>2021-10-04 13:17:30 -0400
committerTony Hutter <[email protected]>2022-06-06 16:57:41 -0700
commit271241187b180021bb63ead8c4eac6637ee412e6 (patch)
treedeb5d15eb0b54b38dc5e839be52bd2072ee71838 /lib
parentfc18fa92c8cf3bd8febed784a15804e86aa08cb5 (diff)
Reject zfs send -RI with nonexistent fromsnap
Right now, zfs send -I dataset@nonexistent dataset@existent fails, but zfs send -RI dataset@nonexistent dataset@existent does not. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Rich Ercolani <[email protected]> Closes #12574 Closes #12575
Diffstat (limited to 'lib')
-rw-r--r--lib/libzfs/libzfs_sendrecv.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/libzfs/libzfs_sendrecv.c b/lib/libzfs/libzfs_sendrecv.c
index a944cc164..899cc84cf 100644
--- a/lib/libzfs/libzfs_sendrecv.c
+++ b/lib/libzfs/libzfs_sendrecv.c
@@ -2144,6 +2144,23 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
return (zfs_error(zhp->zfs_hdl, EZFS_NOENT, errbuf));
}
+ if (fromsnap) {
+ char full_fromsnap_name[ZFS_MAX_DATASET_NAME_LEN];
+ if (snprintf(full_fromsnap_name, sizeof (full_fromsnap_name),
+ "%s@%s", zhp->zfs_name, fromsnap) >=
+ sizeof (full_fromsnap_name)) {
+ err = EINVAL;
+ goto stderr_out;
+ }
+ zfs_handle_t *fromsnapn = zfs_open(zhp->zfs_hdl,
+ full_fromsnap_name, ZFS_TYPE_SNAPSHOT);
+ if (fromsnapn == NULL) {
+ err = -1;
+ goto err_out;
+ }
+ zfs_close(fromsnapn);
+ }
+
if (flags->replicate || flags->doall || flags->props ||
flags->holds || flags->backup) {
char full_tosnap_name[ZFS_MAX_DATASET_NAME_LEN];