prevent possible segfault when creating seek table#4201
Merged
Conversation
Cyan4973
reviewed
Nov 25, 2024
|
|
||
| ZSTD_seekTable* ZSTD_seekTable_create_fromSeekable(const ZSTD_seekable* zs) | ||
| { | ||
| if (zs->seekTable.entries == NULL) return NULL; |
Contributor
There was a problem hiding this comment.
Since we are dereferencing zs here, I would prefer an assert(zs != NULL); just before this statement.
Arguably, it should have been added a few lines below too, but wasn't.
Contributor
Author
There was a problem hiding this comment.
Thanks for your review. I added the assert
Cyan4973
approved these changes
Nov 25, 2024
Cyan4973
left a comment
Contributor
There was a problem hiding this comment.
Indeed, given that ZSTD_seekTable is essentially a limited extract from ZSTD_seekable, it involves copying some content from one side to the other.
And it's a problem if the source doesn't exist (is not initialized).
This simple check is a good fix.
Add a check whether the seek table of a `ZSTD_seekable` is initialized before creating a new seek table from it. Return `NULL`, if the check fails.
rorosen
force-pushed
the
seek-table-create-null-check
branch
from
November 25, 2024 07:57
affa711 to
b683c0d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a check in
ZSTD_seekTable_create_fromSeekablewhether the seek table of aZSTD_seekableis initialized before creating a new seek table from it. Formerly, the function created a segfault when the seek table ofZSTD_seekablewas not initialized.Fixes #4200