-
Notifications
You must be signed in to change notification settings - Fork 163
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
Guard every with_capacity call with a bounds check #298
Conversation
The crate does a lot of pre-allocation based on untrusted input, which can lead to unbounded allocation.
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 looks great, thank you!
I’m sorry for being "that guy", but may I ask for this to be merged and eventually released? ;-) |
src/pe/export.rs
Outdated
"Buffer is too short for {} address table entries", | ||
address_table_entries | ||
); | ||
return Err(error::Error::Malformed(message)); |
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’m wondering if we should introduce a TooShort(count, &’static str) error variant which would do:
“Buffer is too short for {0} {1}” since you write the same boilerplate message every time (and technically allocate)
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.
Good idea! However I noticed that goblin::Error
is not flagged as #[non_exhaustive]
, so adding a new variant would be technically a breaking change :-(
So how about doing that as a followup at a later time so it does not block releasing this fix.
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.
There is a breaking change pending anyway, so it’s perfect timing.
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.
That is good to know, I will do that tomorrow then
Ok merged, @Swatinem thanks for your patience! Hopefully can release this tonight or tomorrow |
0k goblin 0.5 is out, thanks for your patience! |
oof, i forgot scroll went to 2021 edition, that's a bit annoying |
ok i had to yank it, because it's technically broken on the msrv, 1.40; so i have to bump that to edition 2021, which is, unfortunately, 1.56.0 Hopefully we don't have a change of MSRV until the next edition :) |
The crate does a lot of pre-allocation based on untrusted input, which
can lead to unbounded allocation.
This came up in getsentry/symbolic#479, and I see the crate already had some bounds checks for certain parts, though not for Mach-O parsing.
I went a bit overboard and added explicit bounds checks for every place where a
with_capacity
is called.