Make *_unserialize safe to use on buffers in-place
By calling memmove instead of memcpy, and walking the buffer backward from the end, *_unserialize is safe to use in-place. Signed-off-by: Peter Harris <pharris@opentext.com>
This commit is contained in:
parent
28a71c6567
commit
8c1d2021ca
|
@ -1218,12 +1218,13 @@ def _c_serialize(context, self):
|
||||||
|
|
||||||
# unserialize: assign variable size fields individually
|
# unserialize: assign variable size fields individually
|
||||||
if 'unserialize' == context:
|
if 'unserialize' == context:
|
||||||
_c(' *%s = xcb_out;', aux_ptr)
|
_c(' xcb_tmp = ((char *)*_aux)+xcb_buffer_len;')
|
||||||
_c(' xcb_tmp = (char *)(*_aux+1);')
|
param_fields.reverse()
|
||||||
for field in param_fields:
|
for field in param_fields:
|
||||||
if not field.type.fixed_size():
|
if not field.type.fixed_size():
|
||||||
_c(' memcpy(xcb_tmp, %s, %s_len);', field.c_field_name, field.c_field_name)
|
_c(' xcb_tmp -= %s_len;', field.c_field_name)
|
||||||
_c(' xcb_tmp += %s_len;', field.c_field_name)
|
_c(' memmove(xcb_tmp, %s, %s_len);', field.c_field_name, field.c_field_name)
|
||||||
|
_c(' *%s = xcb_out;', aux_ptr)
|
||||||
|
|
||||||
_c('')
|
_c('')
|
||||||
_c(' return xcb_buffer_len;')
|
_c(' return xcb_buffer_len;')
|
||||||
|
|
Loading…
Reference in New Issue