Fix segfault in zfs_do_bookmark()

When invoked with wrong parameters 'zfs bookmark' fails to gracefully
validate user input and crashes.

This is a regression accidentally introduced in 587e228; this commit
adds additional tests to the ZFS Test Suite to exercise this codepath.

Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: KireinaHoro <i@jsteward.moe>
Signed-off-by:  loli10K <ezomori.nozomu@gmail.com>
Closes #7228 
Closes #7229
This commit is contained in:
LOLi
2018-02-26 18:55:18 +01:00
committed by Brian Behlendorf
parent 2a0428f16b
commit 4af6873af6
2 changed files with 31 additions and 2 deletions
+6
View File
@@ -7112,6 +7112,12 @@ zfs_do_bookmark(int argc, char **argv)
goto usage;
}
if (strchr(argv[0], '@') == NULL) {
(void) fprintf(stderr,
gettext("invalid snapshot name '%s': "
"must contain a '@'\n"), argv[0]);
goto usage;
}
if (strchr(argv[1], '#') == NULL) {
(void) fprintf(stderr,
gettext("invalid bookmark name '%s': "