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

Fix issue#2445 Null Pointer Deref #2461

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

haruki3hhh
Copy link

Fix issue 2445:
#2445

@@ -3439,7 +3439,11 @@ Result WastParser::ParseModuleCommand(Script* script, CommandPtr* out_command) {
error.loc.offset, error.message.c_str());
}
}
*module = std::move(*m.get());
if (m) {
*module = std::move(*m.get());
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible for ParseWatModule above to succeed without *m being set?

Would this work instead:

if (errors.length()) { 
  return Result::Error;
}
assert(*m);

Copy link
Contributor

Choose a reason for hiding this comment

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

doesn't ParseWatModule also return a Result? probably a good idea to check that instead.

@haruki3hhh
Copy link
Author

Hi,
After adding this patch, execute the poc, it shows:

# ./wat2wasm ../@POC@
../@POC@:1:2: error: error in quoted module: @0x100000001: unexpected token "|", expected a module field or a module.
(module quote "\7c")
 ^^^^^^

And ASAN is not triggered.

Do you think we should make some further improvements about it?
I'm glad to do it, if needed.

@sbc100
Copy link
Member

sbc100 commented Sep 11, 2024

It would be good to add that as a test case I think. Seems like the kind of test that could also be upstreamed to the wasm spec test suite too (once it lands here).

@haruki3hhh
Copy link
Author

If I want to add it into test case, should I directly add a .txt file to https://github.com/WebAssembly/wabt/tree/main/test/parse?

@haruki3hhh
Copy link
Author

@SoniEx2
Copy link
Contributor

SoniEx2 commented Sep 15, 2024

the test looks great. wonder if it would make sense to upstream it...

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