From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55440) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYbVN-0006AN-9Q for qemu-devel@nongnu.org; Wed, 24 Feb 2016 10:37:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYbVI-0007vM-74 for qemu-devel@nongnu.org; Wed, 24 Feb 2016 10:37:33 -0500 Received: from mail-oi0-x243.google.com ([2607:f8b0:4003:c06::243]:35633) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYbVI-0007vI-1w for qemu-devel@nongnu.org; Wed, 24 Feb 2016 10:37:28 -0500 Received: by mail-oi0-x243.google.com with SMTP id i14so1051106oig.2 for ; Wed, 24 Feb 2016 07:37:27 -0800 (PST) Sender: fluxion Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <1455727675-20625-5-git-send-email-marcandre.lureau@redhat.com> References: <1455727675-20625-1-git-send-email-marcandre.lureau@redhat.com> <1455727675-20625-5-git-send-email-marcandre.lureau@redhat.com> Message-ID: <20160224153716.29588.51829@loki> Date: Wed, 24 Feb 2016 09:37:16 -0600 Subject: Re: [Qemu-devel] [PATCH 4/5] qga: fix off-by-one length check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org Cc: lersek@redhat.com Quoting marcandre.lureau@redhat.com (2016-02-17 10:47:54) > From: Marc-Andr=C3=A9 Lureau > = > Laszlo Ersek said: "The length check is off by one (in the safe direction= ); it > should be (nchars >=3D 2). The processing should be active for the wide s= tring > L"\r\n" -- resulting in the empty wide string --, I believe." > = > Reported-by: Laszlo Ersek > Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Michael Roth > --- > qga/commands-win32.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > = > diff --git a/qga/commands-win32.c b/qga/commands-win32.c > index b20f107..ae8cf3d 100644 > --- a/qga/commands-win32.c > +++ b/qga/commands-win32.c > @@ -1266,7 +1266,7 @@ get_net_error_message(gint error) > if (msg !=3D NULL) { > nchars =3D wcslen(msg); > = > - if (nchars > 2 && > + if (nchars >=3D 2 && > msg[nchars - 1] =3D=3D L'\n' && > msg[nchars - 2] =3D=3D L'\r') { > msg[nchars - 2] =3D L'\0'; > -- = > 2.5.0 >=20