Open to-miz opened 2 years ago
Update: I found [count] A count must be >= 0.
under "optimized-format", see https://ubjson.org/type-reference/container-types/#optimized-format
So there is an annotation for optimized containers but not for strings.
The specification doesn't say how to handle negative values in lengths. I propose that it should be handeled as an error, but this needs to be specified, otherwise parsers will disagree on how to handle this case.
I checked a couple of C/C++ libraries, and they seem to silently cast the value to a size_t and allocating memory, resulting in either crashes or errors. The missing specification seems to have resulted in unsafe implementations.