]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qga: check bytes count read by guest-file-read
authorPrasad J Pandit <pjp@fedoraproject.org>
Wed, 13 Jun 2018 06:16:57 +0000 (11:46 +0530)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 3 Jul 2018 15:58:06 +0000 (10:58 -0500)
While reading file content via 'guest-file-read' command,
'qmp_guest_file_read' routine allocates buffer of count+1
bytes. It could overflow for large values of 'count'.
Add check to avoid it.

Reported-by: Fakhri Zulkifli <mohdfakhrizulkifli@gmail.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Cc: qemu-stable@nongnu.org
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
qga/commands-posix.c
qga/commands-win32.c

index 594d21ef3e35c2dd3f3117a7cd5d7b2849b5c5f7..9284e7166697fe7377ac6512a459029388f7b9dd 100644 (file)
@@ -458,7 +458,7 @@ struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
 
     if (!has_count) {
         count = QGA_READ_COUNT_DEFAULT;
-    } else if (count < 0) {
+    } else if (count < 0 || count >= UINT32_MAX) {
         error_setg(errp, "value '%" PRId64 "' is invalid for argument count",
                    count);
         return NULL;
index 70ee5379f64650a827858012b7c99a4ff497aee2..73f31fa8c25502b87872565a56a79575b89295a6 100644 (file)
@@ -318,7 +318,7 @@ GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
     }
     if (!has_count) {
         count = QGA_READ_COUNT_DEFAULT;
-    } else if (count < 0) {
+    } else if (count < 0 || count >= UINT32_MAX) {
         error_setg(errp, "value '%" PRId64
                    "' is invalid for argument count", count);
         return NULL;