Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes UB when buffersize is zero #234

Merged
merged 1 commit into from
Aug 8, 2024
Merged

Fixes UB when buffersize is zero #234

merged 1 commit into from
Aug 8, 2024

Conversation

TheRandomCharacter
Copy link
Collaborator

Passing invalid pointer to memcpy is UB even if bufferSize is zero.

ol-imorozko
ol-imorozko previously approved these changes Aug 6, 2024
common/stream.h Outdated Show resolved Hide resolved
common/stream.h Show resolved Hide resolved
common/stream.h Outdated Show resolved Hide resolved
common/stream.h Outdated Show resolved Hide resolved
ol-imorozko
ol-imorozko previously approved these changes Aug 8, 2024
common/stream.h Outdated Show resolved Hide resolved
common/stream.h Outdated Show resolved Hide resolved
memcpy behavior is undefined if called with invalid pointers.
We were passing invalid pointers with buffer length 0.
It worked but was exposed when -D_GLIBCXX_ASSERTIONS was enabled

Cleans up stream.h serialization

* Adds specializations for CStyle arrays to stream_in_t, stream_out_t.
* Expands automatically serializing types from trivial types to
trivially copyable.
* Gets rid of memcopying trivially copiable types.
@GeorgyKirichenko GeorgyKirichenko merged commit b793ced into main Aug 8, 2024
8 checks passed
@GeorgyKirichenko GeorgyKirichenko deleted the vtbranch branch August 8, 2024 14:50
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.

3 participants