Skip to content

Commit

Permalink
Fix crash when ignoring warning about missing preinit device
Browse files Browse the repository at this point in the history
MagiskRootPatcher was previously assuming that there is a preinit device
value if the Magisk version requires it.

Signed-off-by: Andrew Gunnerson <[email protected]>
  • Loading branch information
chenxiaolong committed Dec 11, 2024
1 parent 05cd747 commit 5d7eb13
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions avbroot/src/patch/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use std::{
cmp::Ordering,
collections::{HashMap, HashSet},
fmt::Write,
fs::File,
io::{self, BufRead, BufReader, Cursor, Read, Seek},
num::ParseIntError,
Expand Down Expand Up @@ -497,10 +498,9 @@ impl BootImagePatch for MagiskRootPatcher {
magisk_config.push_str("RECOVERYMODE=false\n");

if Self::VER_PREINIT_DEVICE.contains(&self.version) {
magisk_config.push_str(&format!(
"PREINITDEVICE={}\n",
self.preinit_device.as_ref().unwrap(),
));
if let Some(device) = &self.preinit_device {
write!(&mut magisk_config, "PREINITDEVICE={device}\n").unwrap();
}
}

// Magisk normally saves the original SHA1 digest in its config file. It
Expand All @@ -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();
}

trace!("Magisk config: {magisk_config:?}");
Expand Down

0 comments on commit 5d7eb13

Please sign in to comment.