libmultipath: check get_word() result in disassemble_map() - #155
Open
wallycheng wants to merge 1 commit into
Open
libmultipath: check get_word() result in disassemble_map()#155wallycheng wants to merge 1 commit into
wallycheng wants to merge 1 commit into
Conversation
get_word() leaves *word == NULL and returns 0 if its internal calloc() fails, which can happen under memory pressure. Every other call site in disassemble_map() checks for this case, but the path-arguments loop skipped the check before calling atoi(word), causing a NULL-pointer dereference on the OOM path. Jump to the existing out1 label, which already frees word, to match the rest of the function and bail out cleanly. Signed-off-by: wallycheng <295412260@qq.com>
wallycheng
marked this pull request as draft
August 14, 2026 04:12
wallycheng
marked this pull request as ready for review
August 14, 2026 04:13
Author
|
@mwilck Hi, Could you take a look please? Thanks! |
bmarzins
requested changes
Aug 14, 2026
bmarzins
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for the patch! It looks good other than two nitpicks.
- Would you mind changing the commit message? This is not just a problem on OOM (which is unlikely to happen in practice). A malformed multipath table, where the last path has no arguments, will also cause a crash, and that seems like a more likely thing to happen.
- since we know word is NULL, we might as well just jump to
out, instead ofout1.
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.
get_word() leaves *word == NULL and returns 0 if its internal
calloc() fails, which can happen under memory pressure. Every
other call site in disassemble_map() checks for this case, but the
path-arguments loop skipped the check before calling atoi(word),
causing a NULL-pointer dereference on the OOM path.
Jump to the existing out1 label, which already frees word, to
match the rest of the function and bail out cleanly.