qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-stable@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	"open list:Network Block Dev..." <qemu-block@nongnu.org>
Subject: [Qemu-devel] [PULL 1/8] nbd/server: fix nbd_negotiate_handle_info
Date: Thu,  9 Nov 2017 10:59:32 -0600	[thread overview]
Message-ID: <20171109165939.23154-2-eblake@redhat.com> (raw)
In-Reply-To: <20171109165939.23154-1-eblake@redhat.com>

From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

namelen should be here, length is unrelated, and always 0 at this
point.  Broken in introduction in commit f37708f6, but mostly
harmless (replying with '' as the name does not violate protocol,
and does not confuse qemu as the nbd client since our implementation
does not ask for the name; but might confuse some other client that
does ask for the name especially if the default export is different
than the export name being queried).

Adding an assert makes it obvious that we are not skipping any bytes
in the client's message, as well as making it obvious that we were
using the wrong variable.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
CC: qemu-stable@nongnu.org
Message-Id: <20171101154204.27146-1-vsementsov@virtuozzo.com>
[eblake: improve commit message, squash in assert addition]
Signed-off-by: Eric Blake <eblake@redhat.com>
---
 nbd/server.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/nbd/server.c b/nbd/server.c
index 70b40ed27e..bcf0cdb47c 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -423,6 +423,7 @@ static int nbd_negotiate_handle_info(NBDClient *client, uint32_t length,
             break;
         }
     }
+    assert(length == 0);

     exp = nbd_export_find(name);
     if (!exp) {
@@ -433,7 +434,7 @@ static int nbd_negotiate_handle_info(NBDClient *client, uint32_t length,

     /* Don't bother sending NBD_INFO_NAME unless client requested it */
     if (sendname) {
-        rc = nbd_negotiate_send_info(client, opt, NBD_INFO_NAME, length, name,
+        rc = nbd_negotiate_send_info(client, opt, NBD_INFO_NAME, namelen, name,
                                      errp);
         if (rc < 0) {
             return rc;
-- 
2.13.6

  reply	other threads:[~2017-11-09 16:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-09 16:59 [Qemu-devel] [PULL 0/8] NBD patches for 2.11-rc1 Eric Blake
2017-11-09 16:59 ` Eric Blake [this message]
2017-11-09 16:59 ` [Qemu-devel] [PULL 2/8] nbd-client: Fix error message typos Eric Blake
2017-11-09 16:59 ` [Qemu-devel] [PULL 3/8] nbd-client: Refuse read-only client with BDRV_O_RDWR Eric Blake
2017-12-03 19:01   ` Richard W.M. Jones
2017-11-09 16:59 ` [Qemu-devel] [PULL 4/8] nbd/client: Nicer trace of structured reply Eric Blake
2017-11-09 16:59 ` [Qemu-devel] [PULL 5/8] nbd: Fix struct name for structured reads Eric Blake
2017-11-09 16:59 ` [Qemu-devel] [PULL 6/8] nbd-client: Short-circuit 0-length operations Eric Blake
2017-11-09 16:59 ` [Qemu-devel] [PULL 7/8] nbd-client: Stricter enforcing of structured reply spec Eric Blake
2017-11-09 16:59 ` [Qemu-devel] [PULL 8/8] nbd/server: Fix structured read of length 0 Eric Blake
2017-11-13 13:53 ` [Qemu-devel] [PULL 0/8] NBD patches for 2.11-rc1 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171109165939.23154-2-eblake@redhat.com \
    --to=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).