From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46446) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqpQB-0007bw-5o for qemu-devel@nongnu.org; Thu, 14 Apr 2016 18:07:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aqpQ7-0003MT-55 for qemu-devel@nongnu.org; Thu, 14 Apr 2016 18:07:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39979) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqpQ6-0003MA-TG for qemu-devel@nongnu.org; Thu, 14 Apr 2016 18:07:27 -0400 References: <1460077777-31004-1-git-send-email-eblake@redhat.com> <57100C37.5090807@redhat.com> From: Eric Blake Message-ID: <5710149D.5090803@redhat.com> Date: Thu, 14 Apr 2016 16:07:25 -0600 MIME-Version: 1.0 In-Reply-To: <57100C37.5090807@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qSoXxuvOkOivFsImQHGNVWr8uLH1TUi0e" Subject: Re: [Qemu-devel] [PATCH for-2.6] nbd: Don't fail handshake on NBD_OPT_LIST descriptions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: pbonzini@redhat.com, alex@alex.org.uk This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --qSoXxuvOkOivFsImQHGNVWr8uLH1TUi0e Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/14/2016 03:31 PM, Max Reitz wrote: > On 08.04.2016 03:09, Eric Blake wrote: >> The NBD Protocol states that NBD_REP_SERVER may set >> 'length > sizeof(namelen) + namelen'; in which case the rest >> of the packet is a UTF-8 description of the export. While we >> don't know of any NBD servers that send this description yet, >> we had better consume the data so we don't choke when we start >> to talk to such a server. >> >> @@ -214,6 +219,20 @@ static int nbd_receive_list(QIOChannel *ioc, char= **name, Error **errp) >> return -1; >> } >> (*name)[namelen] =3D '\0'; >> + len -=3D namelen; >> + if (len) { >> + char *buf =3D g_malloc(len + 1); >> + if (read_sync(ioc, buf, len) !=3D len) { >> + error_setg(errp, "failed to read export description")= ; >> + g_free(*name); >> + g_free(buf); >> + *name =3D NULL; >> + return -1; >> + } >> + buf[len] =3D '\0'; >> + TRACE("Ignoring export description: %s", buf); >=20 > I find this funny, somehow. >=20 > Perhaps it's because this may explicitly print something while > explaining that it's being ignored. The server.c code had a nice function for skipping unwanted bytes; and in a 2.7 series, I borrowed that idea: https://lists.gnu.org/archive/html/qemu-devel/2016-04/msg01597.html but for the purpose of minimal churn in 2.6, I don't mind the (temporary) oddity. >=20 >> + g_free(buf); >> + } >> } else { >> error_setg(errp, "Unexpected reply type %x expected %x", >> type, NBD_REP_SERVER); >> >=20 > Thanks Eric, I applied this patch to my block branch (for 2.6). If this= > was not your intention, please speak up. :-) >=20 > https://github.com/XanClic/qemu/commits/block You did the right thing. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --qSoXxuvOkOivFsImQHGNVWr8uLH1TUi0e Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXEBSdAAoJEKeha0olJ0NqyMkH/2ID+YJyI2EXsCMqwGiThQSt cf6f2z7S2L2Ut+Hs5MB/n3n4NQyKDt82j4KO+TEPTsXJDzYws/62SCWzJ7ROtKBO LIJMzZyIpEeBc3GEShhoaqlY7NMLwmpZeRWHNEBvMXTSEm9dgRRvrn5MnvPb0Ol7 85JKv8NW53tEFbpFFPzFffjv9fh7uVXPBMde+wDXWlUGg1/qXR81h10+iYvJ67IZ h2+Ywg0lrLKD2yHz5lZoGg5B2kgDRrbrBGCABx/Whvp7YqmavXIEpLAniYXruJmA h+uC6ufZzPFfZnuAWf3nnePLdc2N9fS3whVAMI/KOMq6p98X2IrQinMc1LLAAmY= =ZoP3 -----END PGP SIGNATURE----- --qSoXxuvOkOivFsImQHGNVWr8uLH1TUi0e--