-
Notifications
You must be signed in to change notification settings - Fork 169
Fix some offsets computation when using scroll #471
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
base: master
Are you sure you want to change the base?
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’d like to see a test that fixes whatever bug you had, (which fails today without this patch), otherwise I’m not sure exactly what this fixes for you, can you go into more detail? This appears to only change the pwrite impls which won’t affect the parser iiuc?
@@ -628,7 +631,7 @@ impl ctx::TryIntoCtx<scroll::Endian> for OptionalHeader { | |||
bytes.gwrite_with(self.windows_fields, offset, ctx)?; | |||
bytes.gwrite_with(self.data_directories, offset, ctx)?; | |||
} | |||
_ => panic!(), | |||
n => Err(Self::Error::BadMagic(n.into()))?, |
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 not sure bad magic is the correct error here, I’m sure there’s something more applicable, but thank you for getting rid of this panic, that’s bad?
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 used the same as the one used in src/pe/optional_headers.rs:597
and src/pe/optional_headers.rs:576
to be consistent.
2d1d56a
to
639b23b
Compare
I noticed that for now, the only reason we rely on the method |
While I was working on a personal project using both goblin and scroll, I found some bugs in the way offset are computed for both
DataDirectories
andOptionalHeader
.Here some minor fixes without breaking changes.
While going through the code I notice that most parsing methods are present twices:
parse
of each structsIs there a reason why theses two implementations cohabit? Using only one could reduce bugs and improve maintainability.