mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Avoid core dump on invalid redaction bookmark
libzfs aborts and dumps core on EINVAL from the kernel when trying to do a redacted send with a bookmark that is not a redaction bookmark. Move redacted bookmark validation into libzfs. Check if the bookmark given for redactions is actually a redaction bookmark. Print an error message and exit gracefully if it is not. Don't abort on EINVAL in zfs_send_one. Reviewed-by: Paul Dagnelie <pcd@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #10138
This commit is contained in:
+4
-18
@@ -4408,24 +4408,6 @@ zfs_do_send(int argc, char **argv)
|
||||
if (!(flags.replicate || flags.doall)) {
|
||||
char frombuf[ZFS_MAX_DATASET_NAME_LEN];
|
||||
|
||||
if (redactbook != NULL) {
|
||||
if (strchr(argv[0], '@') == NULL) {
|
||||
(void) fprintf(stderr, gettext("Error: Cannot "
|
||||
"do a redacted send to a filesystem.\n"));
|
||||
return (1);
|
||||
}
|
||||
if (strchr(redactbook, '#') != NULL) {
|
||||
(void) fprintf(stderr, gettext("Error: "
|
||||
"redaction bookmark argument must "
|
||||
"not contain '#'\n"));
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
||||
zhp = zfs_open(g_zfs, argv[0], ZFS_TYPE_DATASET);
|
||||
if (zhp == NULL)
|
||||
return (1);
|
||||
|
||||
if (fromname != NULL && (strchr(fromname, '#') == NULL &&
|
||||
strchr(fromname, '@') == NULL)) {
|
||||
/*
|
||||
@@ -4454,6 +4436,10 @@ zfs_do_send(int argc, char **argv)
|
||||
(void) strlcat(frombuf, tmpbuf, sizeof (frombuf));
|
||||
fromname = frombuf;
|
||||
}
|
||||
|
||||
zhp = zfs_open(g_zfs, argv[0], ZFS_TYPE_DATASET);
|
||||
if (zhp == NULL)
|
||||
return (1);
|
||||
err = zfs_send_one(zhp, fromname, STDOUT_FILENO, &flags,
|
||||
redactbook);
|
||||
zfs_close(zhp);
|
||||
|
||||
Reference in New Issue
Block a user