-
Notifications
You must be signed in to change notification settings - Fork 15
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 panic when accessing union from invalid input #100
Conversation
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 think this is a great PR, however after adding more tests locally I found out that it still had some problems (that originated in my bad suggestions on #99).
I'm making an updated PR that contains a rebase of your commit, so I think we should close this one.
@@ -13,9 +13,9 @@ impl<'buf> Table<'buf> { | |||
buffer: SliceWithStartOffset<'buf>, | |||
field_offset: usize, | |||
) -> Result<Self, ErrorKind> { | |||
let field_value = u32::from_buffer(buffer, field_offset)?; | |||
let object_size = u32::from_buffer(buffer, field_offset)?; |
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.
This code is run primarily when a table is accessed from another table. The "field value" is an offset to where the actual table is. I would be up for a better name for this variable, but object_size
is not better.
let offset = self | ||
.vtable | ||
.get(2 * vtable_offset..2 * (vtable_offset + 2)) | ||
.ok_or_else(|| make_error(ErrorKind::InvalidOffset))?; |
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.
While looking into adding a few extra tests for this, I found out that this should only sometimes be considered an error.
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.
Thanks a lot! Awesome! Yeap feel free to close this one and focus on the improved version. 🚀
Closing as this was included in #102 |
Checklist
Closes #99