From: Marc-André Lureau Date: Wed, 17 Feb 2016 16:47:54 +0000 (+0100) Subject: qga: fix off-by-one length check X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=25d943b95703ae45567395db4156b25052ee54c4;p=qemu.git qga: fix off-by-one length check Laszlo Ersek said: "The length check is off by one (in the safe direction); it should be (nchars >= 2). The processing should be active for the wide string L"\r\n" -- resulting in the empty wide string --, I believe." Reported-by: Laszlo Ersek Signed-off-by: Marc-André Lureau Reviewed-by: Laszlo Ersek Reviewed-by: Michael Roth Signed-off-by: Michael Roth --- diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 2df1e2d61b..043ed684a4 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -1323,7 +1323,7 @@ get_net_error_message(gint error) if (msg != NULL) { nchars = wcslen(msg); - if (nchars > 2 && + if (nchars >= 2 && msg[nchars - 1] == L'\n' && msg[nchars - 2] == L'\r') { msg[nchars - 2] = L'\0';