Skip to content

Commit

Permalink
nbd/client: fix nbd_negotiate_simple_meta_context
Browse files Browse the repository at this point in the history
Initialize received variable. Otherwise, is is possible for server to
answer without any contexts, but we will set context_id to something
random (received_id is not initialized too) and return 1, which is
wrong.

To solve it, just initialize received to false. Initialize received_id
too, just to make all possible checkers happy.

Bug was introduced in 78a33ab "nbd: BLOCK_STATUS for
standard get_block_status function: client part" with the whole
function.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20180427142002.21930-2-vsementsov@virtuozzo.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
CC: qemu-stable@nongnu.org
Signed-off-by: Eric Blake <eblake@redhat.com>
  • Loading branch information
Vladimir Sementsov-Ogievskiy authored and ebblake committed May 4, 2018
1 parent 26bd8d9 commit 89aa0d8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions nbd/client.c
Expand Up @@ -613,8 +613,8 @@ static int nbd_negotiate_simple_meta_context(QIOChannel *ioc,
{
int ret;
NBDOptionReply reply;
uint32_t received_id;
bool received;
uint32_t received_id = 0;
bool received = false;
uint32_t export_len = strlen(export);
uint32_t context_len = strlen(context);
uint32_t data_len = sizeof(export_len) + export_len +
Expand Down

0 comments on commit 89aa0d8

Please sign in to comment.