Replies: 6 comments 7 replies
-
Sorry about the issue noise; I misread several things when posting this. |
Beta Was this translation helpful? Give feedback.
-
false alarm? |
Beta Was this translation helpful? Give feedback.
-
Yeah, is there an actual problem or not? 🤔 And no problem for the issue at all @hans-tvs , even if your assumptions were incorrect, discussion is among the most valuable things we can have here. Which is why i moved it to the discussion page. |
Beta Was this translation helpful? Give feedback.
-
I looked at this more closely, and I'm pretty sure now it wasn't a false alarm: Wire Format SpecThe docs are slightly ambiguous, but the sentence
seems to place an emphasis on the difference being between Other LibrariesThe reason I wrote that PR in the first place is that we were getting oddly encoded negative integers from one of our vendors (64-bits of 1s in the decoded varint vs 32 for an |
Beta Was this translation helpful? Give feedback.
-
If i understand correctly your analysis, the specs means that the varint wire format is always based on i64 data, meaning that for example, if you encode an i32 with value -1, you must encode the equivalent i64 = -1 (resulting in encoding 10 bytes instead of 5)? Only in the case of proto type int32. sint32/sint64 shouldn't be affected by the mistake as they are zig-zag encoded which is something different. int64 should be fine too currently as there is no truncated data in it. I have to check in reference implementations for this, if that's the case that means I fucked up pretty hard from the beginning :( |
Beta Was this translation helpful? Give feedback.
-
zig https://github.com/Arwalk/zig-protobuf/releases/tag/v2.0.0 has been released with the fix, and some informations about how to handle any problem. |
Beta Was this translation helpful? Give feedback.
-
I submitted a PR recently to convert the problem from a panic to a runtime error, but I was under the mistaken impression that the protobuf data we were being given was occasionally broken. Instead, the Python and C++ canonical implementations, along with the docs, indicate that the appropriate order of operations is something like the following:
As opposed to the current logic, which either truncates the extra 4 bytes of decoded data, or fails when any of those extra 4 bytes are 0.
This is likely a (small) problem throughout the codebase, not isolated to enums or any one feature.
Beta Was this translation helpful? Give feedback.
All reactions