Closed m-wichmann closed 7 years ago
Nice to see that you added the error checking!
For your first point, you could define obj_skip_count
as size_t
: http://stackoverflow.com/questions/2550774/what-is-size-t-in-c : size_t is a type guaranteed to hold any array index.
For your first point, you could define obj_skip_count as size_t
I thought about that, but size_t is only guaranteed to be at least 16 bit. Although I don't know of any platform that uses less than 32 bits, it might be a problem for some obscure architectures or compilers. MsgPack allows for arrays and maps to contain up to 2^32 entries (2^33 if you count the keys/values in a map separately). And nested arrays/maps also increment the obj_skip_count. So a single array with 2^32 entries, containing an array with 20 elements will result in an overflow, although it should be valid data. I'm not sure if such a case has to be handled correctly (rather unrealistic data) or if it could be used maliciously.
It is also guaranteed to be able to represent any sizeof() result, therefore it will be at least 32 bit on 32 bit machines and 64 bits on 64 bits machines.
Hey, thank you so much :) :) :+1:
I'll try and dedicate some time to this tomorrow, sorry I've been slacking.
I've started working on a different approach to skipping, functions starting here. Let me know what you think.
Closing this; different implementation has been merged into master.
This is another attempt to add skipping support (see also #5). This implementation is based on code from CWPack and does not use recursion.
Before this is merged, two things should be considered: