Skip to content
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 crash when ignoring warning about missing preinit device #394

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

chenxiaolong
Copy link
Owner

MagiskRootPatcher was previously assuming that there is a preinit device value if the Magisk version requires it.

MagiskRootPatcher was previously assuming that there is a preinit device
value if the Magisk version requires it.

Signed-off-by: Andrew Gunnerson <[email protected]>
@chenxiaolong chenxiaolong self-assigned this Dec 11, 2024
chenxiaolong added a commit that referenced this pull request Dec 11, 2024
Signed-off-by: Andrew Gunnerson <[email protected]>
@chenxiaolong chenxiaolong merged commit 5d7eb13 into master Dec 11, 2024
5 checks passed
@chenxiaolong chenxiaolong deleted the preinit-crash branch December 11, 2024 05:07
@@ -510,7 +510,7 @@ impl BootImagePatch for MagiskRootPatcher {
magisk_config.push_str("SHA1=0000000000000000000000000000000000000000\n");

if Self::VER_RANDOM_SEED.contains(&self.version) {
magisk_config.push_str(&format!("RANDOMSEED={:#x}\n", self.random_seed));
write!(&mut magisk_config, "RANDOMSEED={:#x}\n", self.random_seed).unwrap();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using unwrap() here would result in avbroot to panic if random_seed is null or undefined. Isn't it?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, the unwrap() is for the result of write!(), which cannot fail when appending to a string like magisk_config. (It can fail if writing to some other target, like a file.)

Regarding random_seed, there's no concept of null or undefined in Rust. It is always a valid integer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants