[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] server: Avoid sync bug when NBD_OPT_GO fails with ERR_POLICY



It is imperative that all client data is consumed when replying with
error to NBD_OPT_GO, so that the server will still be in sync if the
client attempts another NBD_OPT_* command.  We got this right a couple
lines earlier when server is NULL, but leave unread client data when
commit_client() fails.

Fixes: e6b56c12 ("Merge branch 'extension-info'", 3.16)
Signed-off-by: Eric Blake <eblake@redhat.com>
---
 nbd-server.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/nbd-server.c b/nbd-server.c
index 216eb00..875c16f 100644
--- a/nbd-server.c
+++ b/nbd-server.c
@@ -2607,6 +2607,8 @@ static bool handle_info(CLIENT* client, uint32_t opt, GArray* servers, uint32_t
 	if (opt == NBD_OPT_GO) {
 		client->clientfeats = cflags;
 		if(!commit_client(client, server)) {
+			consume(client, n_requests * sizeof(request), buf,
+				sizeof(buf));
 			send_reply(client, opt, NBD_REP_ERR_POLICY, -1, "Access denied by server configuration");
 			return false;
 		}
-- 
2.43.2


Reply to: