Skip to content

Commit

Permalink
qga: fix off-by-one length check
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
elmarco authored and mdroth committed Feb 25, 2016
1 parent 6c6916d commit 25d943b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion qga/commands-win32.c
Expand Up @@ -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';
Expand Down

0 comments on commit 25d943b

Please sign in to comment.