Skip to content

Commit

Permalink
Fix 'zpool create' segfault due to bad syntax
Browse files Browse the repository at this point in the history
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 openzfs#1118
  • Loading branch information
lundman authored and unya committed Dec 13, 2013
1 parent 481acc6 commit b7d8093
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/libzfs/libzfs_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down

0 comments on commit b7d8093

Please sign in to comment.