]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs_io: don't walk off the end of argv in fzero_f
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 28 Mar 2019 23:05:01 +0000 (18:05 -0500)
committerEric Sandeen <sandeen@redhat.com>
Thu, 28 Mar 2019 23:05:01 +0000 (18:05 -0500)
commitf019d5b7aa6ba04900147249bf98200a569fe8d9
tree19194fd07790480f975e69fda53ee586be1c66db
parentec5002a8b0685f97c81eb07ca08d49ec3dd024f3
xfs_io: don't walk off the end of argv in fzero_f

The fzero_f function doesn't check that there are enough non-switch
parameters to supply offset and length arguments to fallocate.  As a
result, we can walk off the end of the argv array and crash.  A
secondary problem is that we don't use getopt to detect the -k, which is
not how most xfs_io commands work.

Therefore, use getopt to detect the -k argument and rewire the offset
and length interpretation code to check optind and use argv correctly.
This bug is trivially reproduced by "xfs_io -c 'fzero -k 0' /some/file".

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
io/prealloc.c