]> git.proxmox.com Git - mirror_qemu.git/commitdiff
nbd/client: fix nbd_negotiate_simple_meta_context
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Fri, 27 Apr 2018 14:20:01 +0000 (17:20 +0300)
committerEric Blake <eblake@redhat.com>
Fri, 4 May 2018 13:23:07 +0000 (08:23 -0500)
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 78a33ab58782efdb206de14 "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>
nbd/client.c

index b9e175d1c2724ebdc5bac75a98750e61c3278c76..7f35b5c32328edc2d3301db9de63a6a0e89c1241 100644 (file)
@@ -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 +