mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice-common
synced 2025-12-26 14:18:36 +00:00
Make sure the output array is zero terminated to simplify
code using the output structures.
Changed in generated code:
diff -ru gen/generated_client_demarshallers.c common/generated_client_demarshallers.c
--- gen/generated_client_demarshallers.c 2021-02-21 15:13:42.004307087 +0000
+++ common/generated_client_demarshallers.c 2021-02-21 15:13:58.916513426 +0000
@@ -565,15 +565,24 @@
return NULL;
}
-static uint8_t * parse_array_uint8(uint8_t *message_start, SPICE_GNUC_UNUSED uint8_t *message_end, uint8_t *struct_data, PointerInfo *this_ptr_info)
+static uint8_t * parse_array_uint8_terminated(uint8_t *message_start, SPICE_GNUC_UNUSED uint8_t *message_end, uint8_t *struct_data, PointerInfo *this_ptr_info)
{
uint8_t *in = message_start + this_ptr_info->offset;
uint8_t *end;
end = struct_data;
memcpy(end, in, this_ptr_info->nelements);
+#if defined(__GNUC__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-overflow"
+#endif
+ ((char *) (end))[this_ptr_info->nelements] = 0;
+#if defined(__GNUC__)
+#pragma GCC diagnostic pop
+#endif
in += this_ptr_info->nelements;
end += this_ptr_info->nelements;
+ end += 1;
return end;
}
@@ -622,7 +631,8 @@
dst_info_host_data__array__nelements = host_size__value;
dst_info_host_data__array__nw_size = dst_info_host_data__array__nelements;
- dst_info_host_data__array__mem_size = sizeof(uint8_t) * dst_info_host_data__array__nelements;
+ dst_info_host_data__array__mem_size = sizeof(uint8_t) * dst_info_host_data__array__nelements + sizeof(uint8_t);
+ dst_info_host_data__array__mem_size = SPICE_ALIGN(dst_info_host_data__array__mem_size, 4);
if (SPICE_UNLIKELY(dst_info_host_data__array__nw_size > (uintptr_t) (message_end - message_start - host_data__value))) {
goto error;
}
@@ -650,7 +660,8 @@
dst_info_cert_subject_data__array__nelements = cert_subject_size__value;
dst_info_cert_subject_data__array__nw_size = dst_info_cert_subject_data__array__nelements;
- dst_info_cert_subject_data__array__mem_size = sizeof(uint8_t) * dst_info_cert_subject_data__array__nelements;
+ dst_info_cert_subject_data__array__mem_size = sizeof(uint8_t) * dst_info_cert_subject_data__array__nelements + sizeof(uint8_t);
+ dst_info_cert_subject_data__array__mem_size = SPICE_ALIGN(dst_info_cert_subject_data__array__mem_size, 4);
if (SPICE_UNLIKELY(dst_info_cert_subject_data__array__nw_size > (uintptr_t) (message_end - message_start - cert_subject_data__value))) {
goto error;
}
@@ -685,14 +696,14 @@
out->dst_info.sport = consume_uint16(&in);
out->dst_info.host_size = consume_uint32(&in);
ptr_info[n_ptr].offset = consume_uint32(&in);
- ptr_info[n_ptr].parse = parse_array_uint8;
+ ptr_info[n_ptr].parse = parse_array_uint8_terminated;
ptr_info[n_ptr].dest = (void **)&out->dst_info.host_data;
host_data__array__nelements = out->dst_info.host_size;
ptr_info[n_ptr].nelements = host_data__array__nelements;
n_ptr++;
out->dst_info.cert_subject_size = consume_uint32(&in);
ptr_info[n_ptr].offset = consume_uint32(&in);
- ptr_info[n_ptr].parse = parse_array_uint8;
+ ptr_info[n_ptr].parse = parse_array_uint8_terminated;
ptr_info[n_ptr].dest = (void **)&out->dst_info.cert_subject_data;
cert_subject_data__array__nelements = out->dst_info.cert_subject_size;
ptr_info[n_ptr].nelements = cert_subject_data__array__nelements;
@@ -1050,7 +1061,8 @@
host_data__array__nelements = host_size__value;
host_data__array__nw_size = host_data__array__nelements;
- host_data__array__mem_size = sizeof(uint8_t) * host_data__array__nelements;
+ host_data__array__mem_size = sizeof(uint8_t) * host_data__array__nelements + sizeof(uint8_t);
+ host_data__array__mem_size = SPICE_ALIGN(host_data__array__mem_size, 4);
if (SPICE_UNLIKELY(host_data__array__nw_size > (uintptr_t) (message_end - message_start - host_data__value))) {
goto error;
}
@@ -1078,7 +1090,8 @@
cert_subject_data__array__nelements = cert_subject_size__value;
cert_subject_data__array__nw_size = cert_subject_data__array__nelements;
- cert_subject_data__array__mem_size = sizeof(uint8_t) * cert_subject_data__array__nelements;
+ cert_subject_data__array__mem_size = sizeof(uint8_t) * cert_subject_data__array__nelements + sizeof(uint8_t);
+ cert_subject_data__array__mem_size = SPICE_ALIGN(cert_subject_data__array__mem_size, 4);
if (SPICE_UNLIKELY(cert_subject_data__array__nw_size > (uintptr_t) (message_end - message_start - cert_subject_data__value))) {
goto error;
}
@@ -1107,13 +1120,13 @@
out->sport = consume_uint16(&in);
out->host_size = consume_uint32(&in);
ptr_info[n_ptr].offset = consume_uint32(&in);
- ptr_info[n_ptr].parse = parse_array_uint8;
+ ptr_info[n_ptr].parse = parse_array_uint8_terminated;
ptr_info[n_ptr].dest = (void **)&out->host_data;
ptr_info[n_ptr].nelements = host_data__array__nelements;
n_ptr++;
out->cert_subject_size = consume_uint32(&in);
ptr_info[n_ptr].offset = consume_uint32(&in);
- ptr_info[n_ptr].parse = parse_array_uint8;
+ ptr_info[n_ptr].parse = parse_array_uint8_terminated;
ptr_info[n_ptr].dest = (void **)&out->cert_subject_data;
ptr_info[n_ptr].nelements = cert_subject_data__array__nelements;
n_ptr++;
@@ -1338,7 +1351,8 @@
dst_info_host_data__array__nelements = host_size__value;
dst_info_host_data__array__nw_size = dst_info_host_data__array__nelements;
- dst_info_host_data__array__mem_size = sizeof(uint8_t) * dst_info_host_data__array__nelements;
+ dst_info_host_data__array__mem_size = sizeof(uint8_t) * dst_info_host_data__array__nelements + sizeof(uint8_t);
+ dst_info_host_data__array__mem_size = SPICE_ALIGN(dst_info_host_data__array__mem_size, 4);
if (SPICE_UNLIKELY(dst_info_host_data__array__nw_size > (uintptr_t) (message_end - message_start - host_data__value))) {
goto error;
}
@@ -1366,7 +1380,8 @@
dst_info_cert_subject_data__array__nelements = cert_subject_size__value;
dst_info_cert_subject_data__array__nw_size = dst_info_cert_subject_data__array__nelements;
- dst_info_cert_subject_data__array__mem_size = sizeof(uint8_t) * dst_info_cert_subject_data__array__nelements;
+ dst_info_cert_subject_data__array__mem_size = sizeof(uint8_t) * dst_info_cert_subject_data__array__nelements + sizeof(uint8_t);
+ dst_info_cert_subject_data__array__mem_size = SPICE_ALIGN(dst_info_cert_subject_data__array__mem_size, 4);
if (SPICE_UNLIKELY(dst_info_cert_subject_data__array__nw_size > (uintptr_t) (message_end - message_start - cert_subject_data__value))) {
goto error;
}
@@ -1401,14 +1416,14 @@
out->dst_info.sport = consume_uint16(&in);
out->dst_info.host_size = consume_uint32(&in);
ptr_info[n_ptr].offset = consume_uint32(&in);
- ptr_info[n_ptr].parse = parse_array_uint8;
+ ptr_info[n_ptr].parse = parse_array_uint8_terminated;
ptr_info[n_ptr].dest = (void **)&out->dst_info.host_data;
host_data__array__nelements = out->dst_info.host_size;
ptr_info[n_ptr].nelements = host_data__array__nelements;
n_ptr++;
out->dst_info.cert_subject_size = consume_uint32(&in);
ptr_info[n_ptr].offset = consume_uint32(&in);
- ptr_info[n_ptr].parse = parse_array_uint8;
+ ptr_info[n_ptr].parse = parse_array_uint8_terminated;
ptr_info[n_ptr].dest = (void **)&out->dst_info.cert_subject_data;
cert_subject_data__array__nelements = out->dst_info.cert_subject_size;
ptr_info[n_ptr].nelements = cert_subject_data__array__nelements;
@@ -7582,7 +7597,8 @@
name__array__nelements = name_size__value;
name__array__nw_size = name__array__nelements;
- name__array__mem_size = sizeof(uint8_t) * name__array__nelements;
+ name__array__mem_size = sizeof(uint8_t) * name__array__nelements + sizeof(uint8_t);
+ name__array__mem_size = SPICE_ALIGN(name__array__mem_size, 4);
if (SPICE_UNLIKELY(name__array__nw_size > (uintptr_t) (message_end - message_start - name__value))) {
goto error;
}
@@ -7609,7 +7625,7 @@
out->name_size = consume_uint32(&in);
ptr_info[n_ptr].offset = consume_uint32(&in);
- ptr_info[n_ptr].parse = parse_array_uint8;
+ ptr_info[n_ptr].parse = parse_array_uint8_terminated;
ptr_info[n_ptr].dest = (void **)&out->name;
ptr_info[n_ptr].nelements = name__array__nelements;
n_ptr++;
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Victor Toso <victortoso@redhat.com>
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| codegen.py | ||
| demarshal.py | ||
| Makefile.am | ||
| marshal.py | ||
| meson.build | ||
| ptypes.py | ||
| spice_parser.py | ||