Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix pcompress/zlib implementation (open-mpi#2625)
* pcompress/zlib: Check for correct return values. deflate and inflate with Z_FINISH return Z_STREAM_END on success. All other cases imply that an error occurred or that not enough output space was available. These cases should be treated as errors because: - deflateBound specifies max amount of output bytes to expect - inflate takes length from message into account Signed-off-by: Tobias Stoeckmann <[email protected]> * pcompress/zlib: Use correct data types. On 64 bit systems size_t is larger than uint32_t. This means that performing a memcpy() with sizeof(uint32_t) truncates the value. Also avoid signed data types when unsigned types are better suited. Signed-off-by: Tobias Stoeckmann <[email protected]> * pcompress/zlib: Correctly terminate string. Right now each successful operation leads to out of boundary heap access by not dereferencing the double pointer outstring. This is supposed to terminate the string with a '\0', not setting a char pointer to NULL. Signed-off-by: Tobias Stoeckmann <[email protected]> * pcompress/zlib: Validate input length. Check that input length is not UINT32_MAX to avoid integer overflow. If such an overflow occurs, a malicious peer could trigger an out of boundary heap access when terminating the string with a nul byte. Signed-off-by: Tobias Stoeckmann <[email protected]>
- Loading branch information