uki: Get raw section from UKI#198
Conversation
allisonkarlitskaya
left a comment
There was a problem hiding this comment.
This looks more or less correct now, minus one question. Can you squash the commits since the second one is just deleting most of the code from the first one?
crates/composefs-boot/src/uki.rs
Outdated
| let (pe_header, rest) = PeHeader::ref_from_prefix(rest).ok()?; | ||
| if pe_header.pe_magic != PE_MAGIC { | ||
| return None; | ||
| return Some(Err(UkiError::PortableExecutableError)); |
There was a problem hiding this comment.
Was this change required?
There was a problem hiding this comment.
Not really, but thought it conveys the intent better? If there is a header mismatch then we can consider it as an error
5c42762 to
7c44803
Compare
|
Squashed the commits into one |
crates/composefs-boot/src/uki.rs
Outdated
| /// * `None` - If the PE format is invalid or cannot be parsed | ||
| /// * `Some(Ok(&str))` - If the section is found and contains valid UTF-8 | ||
| /// * `Some(Err(UkiError))` - If the section is missing or contains invalid UTF-8 |
There was a problem hiding this comment.
These docs are wrong now, sorry :(
| /// * `None` - If the PE format is invalid or cannot be parsed | ||
| /// * `Some(Ok(&[u8]))` - If the section is found, containing the raw section data | ||
| /// * `Some(Err(UkiError::MissingSection))` - If the section is not found in the PE file |
There was a problem hiding this comment.
And since you changed the error return below from None to an explicit PortableExecutableError you should add it here (or just change it back)...
There was a problem hiding this comment.
Ah yeah, I guess return type None does make things consistent. I'll revert my change
There was a problem hiding this comment.
Reverted the return type, fixed docs and pushed
Add a function to get the raw section out of a UKI without converting it to a string. Useful in bootc for checking kernel skew while performing soft-reboot Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com> uki: Refactor `get_text_section` to return `Result` In `get_section` return an error on PE Header mismatch Signed-off-by: Pragyan Poudyal <pragyanpoudyal41999@gmail.com>
7c44803 to
5b5bc04
Compare
allisonkarlitskaya
left a comment
There was a problem hiding this comment.
Thanks for the 27 go-arounds :)
:) |
Add a function to get the raw section out of a UKI without converting it to a string.
Useful in bootc for checking kernel skew while performing soft-reboot