diff options
author | Jorgen Lundman <[email protected]> | 2012-11-29 14:56:07 +0900 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2012-12-04 11:15:25 -0800 |
commit | 53c2ec1d1b3ffdc90c1c6516558e6b4da77c2446 (patch) | |
tree | fc318ed70d3e7b85e3d0585f581bc5e84f15b4e4 /lib | |
parent | 2957f38d78d376431ab18d2f576099d682d7a711 (diff) |
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 <[email protected]>
Closes #1118
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzfs/libzfs_util.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/libzfs/libzfs_util.c b/lib/libzfs/libzfs_util.c index 16affd1ce..42700877a 100644 --- a/lib/libzfs/libzfs_util.c +++ b/lib/libzfs/libzfs_util.c @@ -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); } |