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

`CBORGenerator.writeRawUTF8String()` seems to ignore offset #366

Closed nik9000 closed 1 year ago

nik9000 commented 1 year ago

I've encountered an issue when working with cbor where it looks like the writeRawUtf8String is ignoring the offset. I'm no expert, but it looks like this: https://github.com/FasterXML/jackson-dataformats-binary/blob/3f7a994b2a748e0a0782483f4a6d8cfd558082c3/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORGenerator.java#L870 still ignores the offset parameter.

In my version the method's source is:

    @Override
    public void writeRawUTF8String(byte[] raw, int offset, int len)
            throws IOException
    {
        _verifyValueWrite("write String value");
        if (len == 0) {
            _writeByte(BYTE_EMPTY_STRING);
            return;
        }
        _writeLengthMarker(PREFIX_TYPE_TEXT, len);
        _writeBytes(raw, 0, len);
    }

And it certainly isn't touching the offset parameter. I need that one!

cowtowncoder commented 1 year ago

@nik9000 That definitely looks like a straight bug. Thank you for reporting this!

cowtowncoder commented 1 year ago

Thank you for reporting this @nik9000 -- amazing this bug has been there all along :-/

Fix will be included in 2.14.3 / 2.15.0.