diff options
author | Eric Blake <eblake@redhat.com> | 2018-06-21 07:49:37 -0500 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2018-06-21 09:21:34 -0500 |
commit | d8b20291cba6aa9bb295885a34f2b5f05d59d1b2 (patch) | |
tree | 0e9c8106d6cc7a9e1b7798bf48a9301f97a599a2 /nbd | |
parent | ac5de4984df282d64feb4af33b92e0a75652e2b6 (diff) | |
download | qemu-d8b20291cba6aa9bb295885a34f2b5f05d59d1b2.zip qemu-d8b20291cba6aa9bb295885a34f2b5f05d59d1b2.tar.gz qemu-d8b20291cba6aa9bb295885a34f2b5f05d59d1b2.tar.bz2 |
nbd/server: Reject 0-length block status request
The NBD spec says that behavior is unspecified if the client
requests 0 length for block status; but since the structured
reply is documenting as returning a non-zero length, it's
easier to just diagnose this with an EINVAL error than to
figure out what to return.
CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180621124937.166549-1-eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Diffstat (limited to 'nbd')
-rw-r--r-- | nbd/server.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/nbd/server.c b/nbd/server.c index 9e1f227..493a926 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -2007,6 +2007,10 @@ static coroutine_fn int nbd_handle_request(NBDClient *client, "discard failed", errp); case NBD_CMD_BLOCK_STATUS: + if (!request->len) { + return nbd_send_generic_reply(client, request->handle, -EINVAL, + "need non-zero length", errp); + } if (client->export_meta.valid && client->export_meta.base_allocation) { return nbd_co_send_block_status(client, request->handle, blk_bs(exp->blk), request->from, |