qga: check bytes count read by guest-file-read
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>
This commit is contained in:
parent
65650f0182
commit
141b197408
@ -458,7 +458,7 @@ struct GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
|
|||||||
|
|
||||||
if (!has_count) {
|
if (!has_count) {
|
||||||
count = QGA_READ_COUNT_DEFAULT;
|
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",
|
error_setg(errp, "value '%" PRId64 "' is invalid for argument count",
|
||||||
count);
|
count);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -318,7 +318,7 @@ GuestFileRead *qmp_guest_file_read(int64_t handle, bool has_count,
|
|||||||
}
|
}
|
||||||
if (!has_count) {
|
if (!has_count) {
|
||||||
count = QGA_READ_COUNT_DEFAULT;
|
count = QGA_READ_COUNT_DEFAULT;
|
||||||
} else if (count < 0) {
|
} else if (count < 0 || count >= UINT32_MAX) {
|
||||||
error_setg(errp, "value '%" PRId64
|
error_setg(errp, "value '%" PRId64
|
||||||
"' is invalid for argument count", count);
|
"' is invalid for argument count", count);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user