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 #1118
  • Loading branch information
lundman authored and behlendorf committed Dec 4, 2012
1 parent 2957f38 commit 53c2ec1
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 53c2ec1

Please sign in to comment.