bus-message: fix skipping of array fields in !gvariant messages
We copied part of the string into a buffer that was off by two. If the element signature had length one, we'd copy 0 bytes and crash when looking at the "first" byte. Otherwise, we would crash because strncpy would not terminate the string.
This commit is contained in:
parent
0b4775b527
commit
73777ddba5
|
@ -4958,18 +4958,18 @@ static int message_skip_fields(
|
||||||
|
|
||||||
} else if (t == SD_BUS_TYPE_ARRAY) {
|
} else if (t == SD_BUS_TYPE_ARRAY) {
|
||||||
|
|
||||||
r = signature_element_length(*signature+1, &l);
|
r = signature_element_length(*signature + 1, &l);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
assert(l >= 1);
|
assert(l >= 1);
|
||||||
{
|
{
|
||||||
char sig[l-1], *s;
|
char sig[l + 1], *s = sig;
|
||||||
uint32_t nas;
|
uint32_t nas;
|
||||||
int alignment;
|
int alignment;
|
||||||
|
|
||||||
strncpy(sig, *signature + 1, l-1);
|
strncpy(sig, *signature + 1, l);
|
||||||
s = sig;
|
sig[l] = '\0';
|
||||||
|
|
||||||
alignment = bus_type_get_alignment(sig[0]);
|
alignment = bus_type_get_alignment(sig[0]);
|
||||||
if (alignment < 0)
|
if (alignment < 0)
|
||||||
|
|
Binary file not shown.
Loading…
Reference in a new issue