Documenting BSON Errata

69 views
Skip to first unread message

max.o...@gmail.com

unread,
Feb 2, 2016, 6:08:01 PM2/2/16
to BSON
Hello,

I'm documenting quirks & undefined behavior in BSON (negative size parameters, malformed arrays, etc) for my own purposes implementing the standard. I haven't found much documentation of this subject. Are there any articles, posts on this forum, etc that you all are aware of that I could read and cite? Would people like me to post it when I'm done?

Thanks!

D Merriman

unread,
Feb 19, 2016, 4:44:14 PM2/19/16
to BSON
not really afaik -- if something is obviously not allowed (negative size) it would be undefined the behavior of course.

in mongodb if you tried to insert such a document, it should give you an error back, but the BSON spec is just what is legal not what any behavior if malformed should be.

max.o...@gmail.com

unread,
Mar 3, 2016, 4:14:30 PM3/3/16
to BSON
Thank you for your response.

My reading of the spec is that negative sizes are allowed (why else would it explicitly call for signed size parameters?), and that this is handled in an implementation-defined manner, but perhaps I'm being overly literal. :)

Dwight Merriman

unread,
Mar 3, 2016, 5:41:28 PM3/3/16
to bs...@googlegroups.com
i didn't reread everything but the string field it says 

String - The int32 is the number bytes in the (byte*) + 1 (for the trailing '\x00'). The (byte*) is zero or more UTF-8 encoded characters.

since it explicitly says the string is nonnegative length the size must be too. :-)

it could be less cryptic, and there is also the minor question of why is it wasting a bit thats always zero.

i hope for some of this to be cleaned up in a future revision of the spec (which would have a new version number even if changes are minimal).  there has been an attempt to not modify the existing document much as in theory a specification for a certain spec version should never change.

--
You received this message because you are subscribed to the Google Groups "BSON" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bson+uns...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages