set & use encoding options according to XTypes
Two bits of the DDSI encoding "options" field are used by the XTypes spec to indicate the amount of padding that had to be added at the end to reach the nearest 4-byte boundary as required by the DDSI message format. These bits are now set in according with the spec, and for received samples, the padding is subtracted from the inferred size of the data so that, e.g., a struct T { octet x; } will never deserialise as a struct S { octet x, y; }. Signed-off-by: Erik Boasson <eb@ilities.com>
This commit is contained in:
parent
35fcc013af
commit
3574ac6903
2 changed files with 22 additions and 8 deletions
|
@ -301,7 +301,13 @@ static struct ddsi_serdata_default *serdata_default_from_ser_common (const struc
|
|||
|
||||
const bool needs_bswap = (d->hdr.identifier != NATIVE_ENCODING);
|
||||
d->hdr.identifier = NATIVE_ENCODING;
|
||||
if (!dds_stream_normalize (d->data, d->pos, needs_bswap, tp, kind == SDK_KEY))
|
||||
const uint32_t pad = fromBE2u (d->hdr.options) & 2;
|
||||
if (d->pos < pad)
|
||||
{
|
||||
ddsi_serdata_unref (&d->c);
|
||||
return NULL;
|
||||
}
|
||||
else if (!dds_stream_normalize (d->data, d->pos - pad, needs_bswap, tp, kind == SDK_KEY))
|
||||
{
|
||||
ddsi_serdata_unref (&d->c);
|
||||
return NULL;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue