tbeu / matio

MATLAB MAT File I/O Library
https://matio.sourceforge.io
BSD 2-Clause "Simplified" License
330 stars 97 forks source link

Missing error check of function inflateCopy() #145

Closed lc3412 closed 3 years ago

lc3412 commented 3 years ago

Hi,

Function inflateCopy() sets the destination stream as a complete copy of the source stream, returns Z_MEM_ERROR if there is not enough memory, and returns Z_STREAM_ERROR if the source stream state is inconsistent. However, as shown in the following code, several missing error checks take place. https://github.com/tbeu/matio/blob/7a1831b94a73f2cd665bd48f65c8516509d0740e/src/mat.c#L1427

================================================================================

In the following code, though the return values of function inflateCopy() are assigned to the variables. However, the variables are not checked as error codes. https://github.com/tbeu/matio/blob/7a1831b94a73f2cd665bd48f65c8516509d0740e/src/read_data.c#L674 https://github.com/tbeu/matio/blob/7a1831b94a73f2cd665bd48f65c8516509d0740e/src/read_data.c#L1041 https://github.com/tbeu/matio/blob/7a1831b94a73f2cd665bd48f65c8516509d0740e/src/read_data.c#L1180

================================================================================

Furthermore, the return value of function inflateCopy() from other call sites are all checked. See the following code, for example, https://github.com/tbeu/matio/blob/7a1831b94a73f2cd665bd48f65c8516509d0740e/src/mat5.c#L4403-L4407

tbeu commented 3 years ago

Resolved by 38e64d0. Thanks for reporting.