[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4/5] qga: fix off-by-one length check
From: |
marcandre . lureau |
Subject: |
[Qemu-devel] [PATCH 4/5] qga: fix off-by-one length check |
Date: |
Wed, 17 Feb 2016 17:47:54 +0100 |
From: Marc-André Lureau <address@hidden>
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 <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
---
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 != 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';
--
2.5.0
- [Qemu-devel] [PATCH 0/5] qga: win32 guest-set-user-password improvements, marcandre . lureau, 2016/02/17
- [Qemu-devel] [PATCH 1/5] qga: use more idiomatic qemu-style eol operators, marcandre . lureau, 2016/02/17
- [Qemu-devel] [PATCH 2/5] qga: use size_t for wcslen() return value, marcandre . lureau, 2016/02/17
- [Qemu-devel] [PATCH 4/5] qga: fix off-by-one length check,
marcandre . lureau <=
- [Qemu-devel] [PATCH 3/5] qga: use wide-chars constants for wchar_t comparisons, marcandre . lureau, 2016/02/17
- [Qemu-devel] [PATCH 5/5] qga: check utf8-to-utf16 conversion, marcandre . lureau, 2016/02/17
- Re: [Qemu-devel] [PATCH 0/5] qga: win32 guest-set-user-password improvements, Laszlo Ersek, 2016/02/17
- Re: [Qemu-devel] [PATCH 0/5] qga: win32 guest-set-user-password improvements, Michael Roth, 2016/02/24