forked from rust-osdev/uefi-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
loaded_image: make load options API safer
The spec describes `LoadOptions` as "A pointer to the image’s binary load options. See the OptionalData parameter in [section 3.1.3 Load Options] of the Boot Manager chapter for information on the source of the LoadOptions data." The `OptionalData` field is described as "The remaining bytes in the load option descriptor are a binary data buffer that is passed to the loaded image." So there's no guarantee made about the contents of `LoadOptions`; it's arbitrary binary data as far as the UEFI spec is concerned. So it's not necessarily safe to treat the load_options as a `Char16` pointer, since it might not be aligned and might not be null-terminated. That said, the data is *usually* a null-terminated UCS-2 string. The UEFI Shell spec specifies that command-line parameters are passed that way. To safely support both cases, change the `load_options` field to a `u8` pointer, drop the `load_options` method that converts the data to a `&str`, and add two new methods: `load_options_as_bytes` and `load_options_as_cstr16`. The `set_load_options` has also been changed to take a `u8` pointer instead of a `Char16` pointer. rust-osdev#73
- Loading branch information
1 parent
10e6aeb
commit 0b3f481
Showing
3 changed files
with
67 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters