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

cborparser_dup_string: don't modify *buffer until success #261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thiagomacieira
Copy link
Member

We were returning from the function with the memory we had allocated and freed, if the second iteration over the string produced a failure that didn't happen on the first one. This can't happen with pure memory buffers, but can happen with an external data source that fails to produce the same contents twice.

I'm documenting that the values in all error conditions except for OOM are undefined, so one mustn't attempt to use them, even to free. This does not change behaviour of the library, just documents.

But this commit does make it clear the OOM condition will return a valid *buflen and next, the latter of which is new behaviour with this commit.

Fixes #258.

We were returning from the function with the memory we had allocated and
freed, if the second iteration over the string produced a failure that
didn't happen on the first one. This can't happen with pure memory
buffers, but can happen with an external data source that fails to
produce the same contents twice.

I'm documenting that the values in all error conditions except for OOM
are undefined, so one mustn't attempt to use them, even to free. This
does not change behaviour of the library, just documents.

But this commit does make it clear the OOM condition will return a valid
`*buflen` and `next`, the latter of which is new behaviour with this
commit.

Fixes intel#258.

Signed-off-by: Thiago Macieira <[email protected]>
@thiagomacieira thiagomacieira force-pushed the cborparser_dup_string_don_t_modify_buffer_until_success branch from 8e3ec0f to 17cf2f8 Compare November 6, 2024 00:07
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.

[Bug] Double Free in TinyCBOR
1 participant