Skip to content

Commit

Permalink
Endless loop in zpool_do_remove() on platforms with unsigned char
Browse files Browse the repository at this point in the history
On systems where "char" is an unsigned type the value returned by
getopt() will never be negative (-1), leading to an endless loop:
this issue prevents both 'zpool remove' and 'zstreamdump' for
working on some systems.

Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Chris Dunlop <chris@onthe.net.au>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #8789
  • Loading branch information
loli10K authored and behlendorf committed May 28, 2019
1 parent 841a7a9 commit 0869b74
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2239,7 +2239,7 @@ zfs_do_upgrade(int argc, char **argv)
boolean_t showversions = B_FALSE;
int ret = 0;
upgrade_cbdata_t cb = { 0 };
signed char c;
int c;
int flags = ZFS_ITER_ARGS_CAN_BE_PATHS;

/* check options */
Expand Down Expand Up @@ -3933,7 +3933,7 @@ static int
zfs_do_snapshot(int argc, char **argv)
{
int ret = 0;
signed char c;
int c;
nvlist_t *props;
snap_cbdata_t sd = { 0 };
boolean_t multiple_snaps = B_FALSE;
Expand Down
2 changes: 1 addition & 1 deletion cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ zpool_do_remove(int argc, char **argv)
int i, ret = 0;
zpool_handle_t *zhp = NULL;
boolean_t stop = B_FALSE;
char c;
int c;
boolean_t noop = B_FALSE;
boolean_t parsable = B_FALSE;

Expand Down
2 changes: 1 addition & 1 deletion cmd/zstreamdump/zstreamdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ main(int argc, char *argv[])
struct drr_write_embedded *drrwe = &thedrr.drr_u.drr_write_embedded;
struct drr_object_range *drror = &thedrr.drr_u.drr_object_range;
struct drr_checksum *drrc = &thedrr.drr_u.drr_checksum;
char c;
int c;
boolean_t verbose = B_FALSE;
boolean_t very_verbose = B_FALSE;
boolean_t first = B_TRUE;
Expand Down

0 comments on commit 0869b74

Please sign in to comment.