FasterXML / jackson-dataformats-binary

Uber-project for standard Jackson binary format backends: avro, cbor, ion, protobuf, smile
Apache License 2.0
310 stars 133 forks source link

Small bug in byte-alignment for long field names in Smile, symbol table reuse #235

Closed cowtowncoder closed 3 years ago

cowtowncoder commented 3 years ago

As per lgtm.com's warning, it looks like byte-padding in method

    private final String _decodeLongUnicodeName(int[] quads, int byteLen, int quadLen) {

is slightly wrong, as it assumes lastQuadBytes value to be between [1, 4], but it is actually [0, 3]. Looks like this might potentially lead to collision between 2 long strings with lengths divisible by 4, where only some of last 4 characters differ. Coming up with a test may be challenging.

cowtowncoder commented 3 years ago

Looking at this, I do NOT think this actually resulted in actual bug, only (very) slightly suboptimal handling. Will do it nevertheless, but no reproduction since there isn't actual issue as far as I can reason.