Why use a 10 byte array in the write_varint method? #3789
Unanswered
SumitPatel12
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've read the SQLite docs and their flavour of varint says it can span a maximum of 9 bytes.
I looked over the original SQLite implementation, and tursos and both use a 10 byte buffer when writing a varint. If the size is guaranteed to be at most 9, why is the additional byte required?
I tried writing a version with a 9 bytes allocation and ran it through a fuzzer ( it matched the output of the 10 byte version with the 9 bytes version), and it ran for like 10 mins without any errors.
So, my question is why do both of them use a 10 byte buffer when 9 does the job. I may be overlooking something obvious 😅. But this has been bugging me for the longest of times and I'd love to know why it is 10.
Also, if we somehow end up writing to the 10th byte isn't that likely a scenario where we want it logged or alerted of, 10 byte varint violates the original constraint. Isn't that likely to corrupt things downstream? (Not sure of the corruption thing, just throwing it out there)
Beta Was this translation helpful? Give feedback.
All reactions