Skip to content

Conformance Failure With Varint Reads #1067

Open
@cretz

Description

@cretz

I am failing when running official Google protobuf conformance tests. When using this lib version 6.8.6 (latest) and Google's lib version 3.5.0 (latest), I distilled it to the following test:

const bytes = Uint8Array.from([185, 224, 128, 128, 128, 128, 128, 128, 0, 8, 255, 255, 255, 255, 7])

const pbRdr = require('protobufjs/light').Reader.create(bytes)
console.log('Start pos - ', pbRdr.pos)
console.log('Int32 - ', pbRdr.int32())
console.log('End pos - ', pbRdr.pos)
console.log('Next Int32 - ', pbRdr.int32())

const googRdr = require('google-protobuf').BinaryReader.alloc(bytes).decoder_
console.log('Start pos - ', googRdr.getCursor())
console.log('Int32 - ', googRdr.readSignedVarint32())
console.log('End pos - ', googRdr.getCursor())
console.log('Next Int32 - ', googRdr.readSignedVarint32())

This outputs:

Start pos -  0
Int32 -  12345
End pos -  10
Next Int32 -  2147483647
Start pos -  0
Int32 -  12345
End pos -  9
Next Int32 -  8

Note how this library reads one too far compared to the Google library. Is this buggy or am I misreading? It is breaking my tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions