-
Notifications
You must be signed in to change notification settings - Fork 10
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
Implement fd_fdstat_get #309
Conversation
src/wasi/WASI.cpp
Outdated
class TemporaryData { | ||
public: | ||
TemporaryData(size_t size) | ||
{ | ||
/* Check that more memory is requested than the maximum provided by malloc. */ | ||
if (size > ((~static_cast<size_t>(0)) / sizeof(T))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this case possible?
It seems that this case would rarely happen, and not a intended operation.
So what about checking it simply with ASSERT
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The size comes from WebAssembly, it can intentionally be a bad value (security). On 32 bit, the value can overflow and cause a crash.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, then what about using std::numeric_limits<size_t>
here?
It could be more intuitive I think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I have updated the patch
Regarding Lines 551 to 555 in 20d770b
|
I have tried to use VectorWithInlineStorage, but it throws exceptions on allocation failures. Shall I add try-catch blocks to handle this? |
That would be more complicated, IMHO it's better to use specific |
Improve other WASI functions as well. Signed-off-by: Zoltan Herczeg [email protected]
50f6317
to
db249a2
Compare
Improve other WASI functions as well.