[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 8/9] qga: check utf8-to-utf16 conversion
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PULL 8/9] qga: check utf8-to-utf16 conversion |
Date: |
Thu, 25 Feb 2016 11:12:00 -0600 |
From: Marc-André Lureau <address@hidden>
UTF8 to UTF16 conversion can fail for genuine reasons, let's check errors.
Reported-by: Laszlo Ersek <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Laszlo Ersek <address@hidden>
Reviewed-by: Michael Roth <address@hidden>
Signed-off-by: Michael Roth <address@hidden>
---
qga/commands-win32.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 043ed68..d76327f 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -1349,8 +1349,9 @@ void qmp_guest_set_user_password(const char *username,
NET_API_STATUS nas;
char *rawpasswddata = NULL;
size_t rawpasswdlen;
- wchar_t *user, *wpass;
+ wchar_t *user = NULL, *wpass = NULL;
USER_INFO_1003 pi1003 = { 0, };
+ GError *gerr = NULL;
if (crypted) {
error_setg(errp, QERR_UNSUPPORTED);
@@ -1364,8 +1365,15 @@ void qmp_guest_set_user_password(const char *username,
rawpasswddata = g_renew(char, rawpasswddata, rawpasswdlen + 1);
rawpasswddata[rawpasswdlen] = '\0';
- user = g_utf8_to_utf16(username, -1, NULL, NULL, NULL);
- wpass = g_utf8_to_utf16(rawpasswddata, -1, NULL, NULL, NULL);
+ user = g_utf8_to_utf16(username, -1, NULL, NULL, &gerr);
+ if (!user) {
+ goto done;
+ }
+
+ wpass = g_utf8_to_utf16(rawpasswddata, -1, NULL, NULL, &gerr);
+ if (!wpass) {
+ goto done;
+ }
pi1003.usri1003_password = wpass;
nas = NetUserSetInfo(NULL, user,
@@ -1378,6 +1386,11 @@ void qmp_guest_set_user_password(const char *username,
g_free(msg);
}
+done:
+ if (gerr) {
+ error_setg(errp, QERR_QGA_COMMAND_FAILED, gerr->message);
+ g_error_free(gerr);
+ }
g_free(user);
g_free(wpass);
g_free(rawpasswddata);
--
1.9.1
- [Qemu-devel] [PULL 0/9] qemu-ga patch queue for 2.6, Michael Roth, 2016/02/25
- [Qemu-devel] [PULL 3/9] qga: implement the guest-get-vcpus for windows, Michael Roth, 2016/02/25
- [Qemu-devel] [PULL 1/9] qga: Support enum names in guest-file-seek, Michael Roth, 2016/02/25
- [Qemu-devel] [PULL 9/9] qga: fix w32 breakage due to missing osdep.h includes, Michael Roth, 2016/02/25
- [Qemu-devel] [PULL 7/9] qga: fix off-by-one length check, Michael Roth, 2016/02/25
- [Qemu-devel] [PULL 5/9] qga: use size_t for wcslen() return value, Michael Roth, 2016/02/25
- [Qemu-devel] [PULL 2/9] qemu-ga: Fixed minor version switch issue, Michael Roth, 2016/02/25
- [Qemu-devel] [PULL 8/9] qga: check utf8-to-utf16 conversion,
Michael Roth <=
- [Qemu-devel] [PULL 6/9] qga: use wide-chars constants for wchar_t comparisons, Michael Roth, 2016/02/25
- [Qemu-devel] [PULL 4/9] qga: use more idiomatic qemu-style eol operators, Michael Roth, 2016/02/25
- Re: [Qemu-devel] [PULL 0/9] qemu-ga patch queue for 2.6, Peter Maydell, 2016/02/25