Fix 'zpool create' segfault due to bad syntax

Incorrect syntax should never cause a segfault.  In this case
listing multiple comma delimited options after '-o' triggered
the problem.  For example:

  zpool create -o ashift=12,listsnaps=on

This patch resolves the issue by wrapping the calls which use
hdr with a NULL test.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1118
This commit is contained in:
Jorgen Lundman 2012-11-29 14:56:07 +09:00 committed by Brian Behlendorf
parent 2957f38d78
commit 53c2ec1d1b
1 changed files with 6 additions and 4 deletions

View File

@ -1297,8 +1297,9 @@ str2shift(libzfs_handle_t *hdl, const char *buf)
break;
}
if (i == strlen(ends)) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"invalid numeric suffix '%s'"), buf);
if (hdl)
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"invalid numeric suffix '%s'"), buf);
return (-1);
}
@ -1313,8 +1314,9 @@ str2shift(libzfs_handle_t *hdl, const char *buf)
buf[3] == '\0'))))
return (10*i);
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"invalid numeric suffix '%s'"), buf);
if (hdl)
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"invalid numeric suffix '%s'"), buf);
return (-1);
}