Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protobuf pattern does not support field numbers > 15 #152

Open
prosenkranz opened this issue Aug 14, 2023 · 1 comment
Open

Protobuf pattern does not support field numbers > 15 #152

prosenkranz opened this issue Aug 14, 2023 · 1 comment

Comments

@prosenkranz
Copy link

As per Protobuf Documentation, "Tags" (Keys) of Records/Keys are encoded as VarInts / LEB128.

However the current Protobuf pattern assumes Keys are always 1 byte:

} [[bitfield_order(std::core::BitfieldOrder::MostToLeastSignificant, 8)]];

This assumption will not work anymore for larger (>15) field numbers, where the varint will be 2 bytes long:

CodedOutputStream stream = ...;
stream.writeUInt(16, 0);

The output binary will be:

80 01 00

The value byte here is expected to be 0. The current pattern will incorrectly interpret the second byte as the value 1.

@jumanji144
Copy link
Collaborator

This can be solved by replacing the bitfield with a uleb128 and logical bit shifts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants