lowRISC / opentitan

OpenTitan: Open source silicon root of trust
https://www.opentitan.org
Apache License 2.0
2.57k stars 771 forks source link

[ujson] CRC incorrect for undeliminated values #19373

Open HU90m opened 1 year ago

HU90m commented 1 year ago

The CRC values are incorrect when deserialising a bare undeliminated values, such as a single enum.

The C ujson deserialiser reads the trailing newline when deserialising this type, as it has no other way of knowing the last character. This means the deserialilser gets the next whitespace character and the crc calculation includes this character, which is not part of the ujson message so the CRC value is incorrect.

msfschaffner commented 1 year ago

CC @cfrantz @pamaury @timothytrippel

cfrantz commented 1 year ago

As far as I'm aware, this should only affect numbers and the values true and false. Strings, maps and lists are delimited and any values contained within a map or list are delimited by them.