offset: Better handling of parameters
commit094d387e49ec4f9d5c36a5abc341c6b8424a3087
authorEric Blake <eblake@redhat.com>
Wed, 28 Aug 2019 20:40:39 +0000 (28 15:40 -0500)
committerEric Blake <eblake@redhat.com>
Wed, 28 Aug 2019 21:32:13 +0000 (28 16:32 -0500)
treecb013ec1a9ef1c0e84bc7f6b75b8bbe48eafadf4
parent2fdd6aac900aa3933bce73bdbe5804e5fe483c80
offset: Better handling of parameters

The man page claims both offset and range are optional (matching the
code), but the --help text claims offset is mandatory, and the comment
to the no-op offset_config_complete claims we require both parameters.
We did not check for an offset larger than the underlying size when
there was no range, and even when there is a range, we were not
careful about integer overflow (offset=5E range=5E happily claims to
export a 5E image; but all bets are off if you later try to access
beyond the real underlying size).  And in several cases, such as if
the plugin's get_size fails but range was not provided, we are not
returning -1 for failure.

Fixes: 3db69f56
Signed-off-by: Eric Blake <eblake@redhat.com>
filters/offset/offset.c