Skip to content

Two bugs: size_t >=0 and empty array/objects#5

Open
jpoag wants to merge 2 commits intoSteve132:masterfrom
jpoag:master
Open

Two bugs: size_t >=0 and empty array/objects#5
jpoag wants to merge 2 commits intoSteve132:masterfrom
jpoag:master

Conversation

@jpoag
Copy link

@jpoag jpoag commented Nov 1, 2016

Two bugs found:

  1. There is a size_t comparison >= 0 of constant, which always evaluates to TRUE as size_t is unsigned
  2. The size of an Array/Object can be zero, need to determine if size has been read

Notes on # 2:
I was testing the compatibility between this library and another converter and the converter wrote an empty array as: '[' '#' 'i' '0'

Unfortunately, this ubjson parser was using the zero size to determine whether or not to read the closing array marker ']'. This caused a stack overflow on some files and infinite recursion on others...

I have suggested to the other library to write empty arrays as '[' ']', however, it is not technically wrong to have a zero sized container, as per spec:

A count must be >= 0.

jpoag added 2 commits November 1, 2016 13:28
* size of array or object can be zero, need to determine if size is read
@jpoag jpoag mentioned this pull request Nov 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant