]> www.infradead.org Git - users/dwmw2/qemu.git/commit
nbd/server: Refactor zero-length option check
authorEric Blake <eblake@redhat.com>
Fri, 27 Oct 2017 10:40:31 +0000 (12:40 +0200)
committerEric Blake <eblake@redhat.com>
Mon, 30 Oct 2017 20:47:18 +0000 (21:47 +0100)
commite68c35cfb8088a11300371751e3987f67cac15b1
treef39838ac71f66f4af60a30998fd04757a87d2f09
parent8cbee49ed7348e9b2b708d75c8ff8941032cb488
nbd/server: Refactor zero-length option check

Consolidate the response for a non-zero-length option payload
into a new function, nbd_reject_length().  This check will
also be used when introducing support for structured replies.

Note that STARTTLS response differs based on time: if the connection
is still unencrypted, we set fatal to true (a client that can't
request TLS correctly may still think that we are ready to start
the TLS handshake, so we must disconnect); while if the connection
is already encrypted, the client is sending a bogus request but
is no longer at risk of being confused by continuing the connection.

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20171027104037.8319-7-eblake@redhat.com>
[eblake: correct return value on STARTTLS]
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
nbd/server.c