diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2015-11-23 15:37:07 +0000 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2015-12-18 16:25:08 +0000 |
commit | 920639cab0fe28d003c90b53bd8b66e8fb333bdd (patch) | |
tree | 6140738c5da2a22c018f9e24c3303c85235ba551 /qga/commands-posix.c | |
parent | e9cf2fe07ff70e939f80c624b44c10a4442eef0b (diff) |
qga: convert to use error checked base64 decode
Switch from using g_base64_decode over to qbase64_decode
in order to get error checking of the base64 input data.
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Diffstat (limited to 'qga/commands-posix.c')
-rw-r--r-- | qga/commands-posix.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/qga/commands-posix.c b/qga/commands-posix.c index c2ff97021f..8fe708f001 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -29,6 +29,7 @@ #include "qemu/queue.h" #include "qemu/host-utils.h" #include "qemu/sockets.h" +#include "qemu/base64.h" #ifndef CONFIG_HAS_ENVIRON #ifdef __APPLE__ @@ -525,7 +526,10 @@ GuestFileWrite *qmp_guest_file_write(int64_t handle, const char *buf_b64, gfh->state = RW_STATE_NEW; } - buf = g_base64_decode(buf_b64, &buf_len); + buf = qbase64_decode(buf_b64, -1, &buf_len, errp); + if (!buf) { + return NULL; + } if (!has_count) { count = buf_len; @@ -1963,7 +1967,10 @@ void qmp_guest_set_user_password(const char *username, char *chpasswddata = NULL; size_t chpasswdlen; - rawpasswddata = (char *)g_base64_decode(password, &rawpasswdlen); + rawpasswddata = (char *)qbase64_decode(password, -1, &rawpasswdlen, errp); + if (!rawpasswddata) { + return; + } rawpasswddata = g_renew(char, rawpasswddata, rawpasswdlen + 1); rawpasswddata[rawpasswdlen] = '\0'; |