Eric Blake
2016-May-20 14:04 UTC
[Libguestfs] [PATCH] 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.5.5
Richard W.M. Jones
2016-May-20 14:31 UTC
Re: [Libguestfs] [PATCH] protocol: Ignore rest of option when replying with error
On Fri, May 20, 2016 at 08:04:05AM -0600, Eric Blake wrote:> 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>Thanks Eric, I have pushed this. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
Seemingly Similar Threads
- [PATCH nbdkit 2/2] server: Split out NBD protocol code from connections code.
- [PATCH nbdkit v2] protocol: Implement NBD_OPT_GO.
- [PATCH nbdkit 3/3] server: Remove explicit connection parameter, use TLS instead.
- [nbdkit PATCH] connections: Don't use uninit memory on early client EOF
- [nbdkit PATCH] connections: Implement NBD_OPT_INFO