Skip to content

Fix unlikely buffer overruns - #611

Merged
nmoinvaz merged 2 commits into
zlib-ng:devfrom
peterh:dev
Feb 17, 2022
Merged

nmoinvaz merged 2 commits into
zlib-ng:devfrom
peterh:dev

Conversation

@peterh

@peterh peterh commented Feb 17, 2022

Copy link
Copy Markdown
Contributor

One string length calculation in int16, and one missing NUL terminator.

strncpy does not guarantee that the buffer ends with an ASCII NUL byte.
Force the last byte of directory to be a 0.
If a path of length 0x10001 is passed into this function, the value of
len after truncating to int16_t will be greater than 0, so the function
will proceed to allocate a 2 byte buffer and copy 65538 bytes into it.

Avoid issues with truncation by keeping len in size_t.
@nmoinvaz
nmoinvaz merged commit 27f2ff2 into zlib-ng:dev Feb 17, 2022
@nmoinvaz

Copy link
Copy Markdown
Member

Thanks!

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.

2 participants