Skip to content

libmultipath: check get_word() result in disassemble_map() - #155

Open
wallycheng wants to merge 1 commit into
opensvc:masterfrom
wallycheng:fix-dmparser-null-check
Open

libmultipath: check get_word() result in disassemble_map()#155
wallycheng wants to merge 1 commit into
opensvc:masterfrom
wallycheng:fix-dmparser-null-check

Conversation

@wallycheng

Copy link
Copy Markdown

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.

  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
wallycheng marked this pull request as draft August 14, 2026 04:12
@wallycheng
wallycheng marked this pull request as ready for review August 14, 2026 04:13
@wallycheng

Copy link
Copy Markdown
Author

@mwilck Hi, Could you take a look please? Thanks!

@bmarzins bmarzins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! It looks good other than two nitpicks.

  1. 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.
  2. since we know word is NULL, we might as well just jump to out, instead of out1.

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