billvaglienti / ProtoGen

Communications protocol generation software
MIT License
30 stars 16 forks source link

String defaults ignore packet bounds check #74

Closed jefffisher closed 6 years ago

jefffisher commented 6 years ago

If a string data member is added to a packet with a default value, the default value is set, but then overwritten by bogus data after the end of the packet. As an example, I generated a packet encode function with this XML spec:

<Packet name="Test" ID="100">
    <Data name="Field0" inMemoryType="unsigned32"/>
</Packet>

Then I generated the decode function using this spec:

<Packet name="Test" ID="100">
    <Data name="Field0" inMemoryType="unsigned32"/>
    <Data name="Field1" inMemoryType="string" array="32" default="test"/>
</Packet>

The results can be seen here, including a fixed decode function: https://repl.it/@jefffisher/ChiefAwareMonotone

billvaglienti commented 6 years ago

Fixed in 2.14.d. I just never implemented the intended logic.