summaryrefslogtreecommitdiffstats
path: root/backends
diff options
context:
space:
mode:
Diffstat (limited to 'backends')
-rw-r--r--backends/dbus-vmstate.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/backends/dbus-vmstate.c b/backends/dbus-vmstate.c
index 2a0d2e4a31..9cfd758c42 100644
--- a/backends/dbus-vmstate.c
+++ b/backends/dbus-vmstate.c
@@ -204,6 +204,8 @@ static int dbus_vmstate_post_load(void *opaque, int version_id)
m = g_memory_input_stream_new_from_data(self->data, self->data_size, NULL);
s = g_data_input_stream_new(m);
g_data_input_stream_set_byte_order(s, G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN);
+ g_buffered_input_stream_set_buffer_size(G_BUFFERED_INPUT_STREAM(s),
+ DBUS_VMSTATE_SIZE_LIMIT);
nelem = g_data_input_stream_read_uint32(s, NULL, &err);
if (err) {
@@ -244,11 +246,23 @@ static int dbus_vmstate_post_load(void *opaque, int version_id)
}
len = g_data_input_stream_read_uint32(s, NULL, &err);
+ if (len > DBUS_VMSTATE_SIZE_LIMIT) {
+ error_report("%s: Invalid vmstate size: %u", __func__, len);
+ return -1;
+ }
+
+ g_buffered_input_stream_fill(G_BUFFERED_INPUT_STREAM(s), len, NULL,
+ &err);
+ if (err) {
+ goto error;
+ }
+
avail = g_buffered_input_stream_get_available(
G_BUFFERED_INPUT_STREAM(s));
-
- if (len > DBUS_VMSTATE_SIZE_LIMIT || len > avail) {
- error_report("%s: Invalid vmstate size: %u", __func__, len);
+ if (len > avail) {
+ error_report("%s: Not enough data available to load for Id: '%s'. "
+ "Available data size: %zu, Actual vmstate size: %u",
+ __func__, id, avail, len);
return -1;
}