zserio
zserio copied to clipboard
Range check for dynamic field length
There is no range check for dynamic field length during runtime. Example:
struct Container
{
uint64 length;
bit<length> unsignedBitField;
int<length> signedBitField;
};
It would be nice to have runtime range check that length
is not bigger than 64
. Currently, this issue is reported only during writing without any specification of problematic field.
Note that with -withRangeCheckCode
the check for maximum numbits is done (see BitFieldUtil.cpp
, bitfield.py
, Util.java
. It's only missing in Java for unsigned bitfields which are mapped to BigInteger
.
However it's only a part of range check, which primary task is to check the range of the stored value, not the number of bits. The length
should be checked even -withoutRangeCheckCode
. Currently in Java it's possible to write/read dynamic unsigned bitfield with length > 64bits.