Skip to content

sfixed64 are smaller by a factor of 2 #692

@tomergg

Description

@tomergg

protobuf.js version: v6.6.4

When deserializing sfixed64 values, the Long object returned contains data that is smaller by a factor of 2.
I've compared v5.0.2 results with v6.6.4.

  • Identical base 64 input
  • output of Long values is different by a factor of 2

v6.6.4

const pbEntity = pbRoot.lookup(schema);
const buffer = Buffer.from(base64Data, 'base64');
const entity = pbEntity.decode(buffer).toObject({ bytes: String, enums: String, arrays: true });

v5.0.2

const entity = protoBufBuilder.build(schema).decode(base64Data).toRaw(true);

When I removed the zzDecode call, I got correct results:

function read_sfixed64_long() {
    return readFixed64.call(this).toLong();
}

instead of:

function read_sfixed64_long() {
    return readFixed64.call(this).zzDecode().toLong();
}

I think that the implementation might need to be identical to fixed64.
If needed, I can write some code to repro the problem in isolation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions