]> www.infradead.org Git - users/hch/xfsprogs.git/commit
xfsprogs: fix silently broken option parsing
authorDave Chinner <dchinner@redhat.com>
Wed, 8 Apr 2020 13:48:04 +0000 (09:48 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 8 Apr 2020 13:48:04 +0000 (09:48 -0400)
commit78aeaffda9996d2db98130d2bffdc3ae17539e83
tree486e8dbd817022cf4248ae29e9c69b5cae75ac0e
parent2582ae0d770560960f87d8e921be543fc2caa40d
xfsprogs: fix silently broken option parsing

When getopt() is passed an option string like "-m -n" and the
parameter m is defined as "m:", getopt returns a special error
to indication that the optstring started with a "-". Any getopt()
caller that is just catching the "?" error character will not
not catch this special error, so it silently eats the parameter
following -m.

Lots of getopt loops in xfsprogs have this issue. Convert them all
to just use a "default:" to catch anything unexpected.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
copy/xfs_copy.c
db/freesp.c
db/init.c
growfs/xfs_growfs.c
io/copy_file_range.c
logprint/logprint.c
mkfs/xfs_mkfs.c
repair/xfs_repair.c
scrub/xfs_scrub.c
spaceman/freesp.c
spaceman/prealloc.c