nbdkit/0011-protocol-Ignore-rest-of-option-when-replying-with-er.patch

47 lines
1.5 KiB
Diff
Raw Normal View History

From 7938bbc463a694aeda888d51f1de446f23402d8f Mon Sep 17 00:00:00 2001
From: Eric Blake <eblake@redhat.com>
Date: Fri, 20 May 2016 08:04:05 -0600
Subject: [PATCH 11/11] protocol: Ignore rest of option when replying with
error
We must consume the payload of any option received, whether or
not we can answer the option successfully, in order to be in
sync for reading the next option. This is particularly true
once clients start using NBD_OPT_GO, as long as we don't happen
to service that option.
Signed-off-by: Eric Blake <eblake@redhat.com>
---
src/connections.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/connections.c b/src/connections.c
index 0c93f35..840e315 100644
--- a/src/connections.c
+++ b/src/connections.c
@@ -334,6 +334,10 @@ _negotiate_handshake_newstyle_options (struct connection *conn)
if (send_newstyle_option_reply (conn, option, NBD_REP_ERR_INVALID)
== -1)
return -1;
+ if (xread (conn->sockin, data, optlen) == -1) {
+ nbdkit_error ("read: %m");
+ return -1;
+ }
continue;
}
@@ -351,6 +355,10 @@ _negotiate_handshake_newstyle_options (struct connection *conn)
/* Unknown option. */
if (send_newstyle_option_reply (conn, option, NBD_REP_ERR_UNSUP) == -1)
return -1;
+ if (xread (conn->sockin, data, optlen) == -1) {
+ nbdkit_error ("read: %m");
+ return -1;
+ }
}
/* Note, since it's not very clear from the protocol doc, that the
--
2.7.4