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 <lersek@redhat.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
This commit is contained in:
Marc-André Lureau 2016-02-17 17:47:54 +01:00 committed by Michael Roth
parent 6c6916dac8
commit 25d943b957
1 changed files with 1 additions and 1 deletions

View File

@ -1323,7 +1323,7 @@ get_net_error_message(gint error)
if (msg != NULL) { if (msg != NULL) {
nchars = wcslen(msg); nchars = wcslen(msg);
if (nchars > 2 && if (nchars >= 2 &&
msg[nchars - 1] == L'\n' && msg[nchars - 1] == L'\n' &&
msg[nchars - 2] == L'\r') { msg[nchars - 2] == L'\r') {
msg[nchars - 2] = L'\0'; msg[nchars - 2] = L'\0';