amazon-ion / ion-c

A C implementation of Amazon Ion.
https://amazon-ion.github.io/ion-docs/
Apache License 2.0
166 stars 43 forks source link

BLOB/CLOB's of size zero fail during read process #331

Closed ezabes closed 3 months ago

ezabes commented 1 year ago

When the ion reader is trying to read a BLOB/CLOB/byte array of length zero, buf_max is assigned to equal 0 and enters an endless loop upon testing an assertion.

ASSERT(buf_max)

This line appears at line 1747 in ion_reader.c in function: iERR _ion_reader_read_lob_bytes_helper Line also appears at line 1950 in ion_reader_text.c in function: iERR _ion_reader_text_read_lob_bytes

Note the function: iERR ion_reader_read_lob_bytes tests buf_max before calling function _ion_reader_read_lob_bytes_helper

if (buf_max < 0) FAILWITH(IERR_INVALID_ARG);

The line in ion_reader_binary.c appears as:

ASSERT(buf_max >= 0);

Changing the ASSERTS in ion_reader.c and ion_reader_text.c to match the ion_reader_binary appears to resolve the issue.

nirosys commented 1 year ago

Oh my, thank you again ezabes. :) We'll hopefully get to look at this in the next couple days. Thank you again, we really appreciate your issue submissions.

nirosys commented 3 months ago

Thank you again ezabes for reporting this issue! #348 has been merged to address the problem.