mirror of
https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation.git
synced 2026-08-09 15:19:11 +02:00
fix(core): two bugs blocking package operations on real devices (#1430)
* fix(core): two bugs blocking package operations on real devices - adb.rs: replace debug_assert! in list_packages_sys with filter_map to avoid panicking on nonstandard package names from real devices. - sync.rs: fix inverted guard in request_builder (is_some -> is_none) that was rejecting every valid package name instead of invalid ones.
This commit is contained in:
parent
596120a215
commit
43d323332f
2 changed files with 9 additions and 5 deletions
|
|
@ -44,7 +44,7 @@ use std::rc::Rc;
|
|||
use std::os::windows::process::CommandExt;
|
||||
|
||||
use crate::utils::is_all_w_c;
|
||||
use log::{error, info};
|
||||
use log::{error, info, warn};
|
||||
|
||||
/// Convert ADB output bytes to a trimmed UTF-8 string.
|
||||
/// Uses lossy conversion to prevent panics on non-UTF8 output from certain OEMs.
|
||||
|
|
@ -366,11 +366,15 @@ impl PmCommand {
|
|||
self.0.0.run().map(|pack_ls| {
|
||||
pack_ls
|
||||
.lines()
|
||||
.map(|p_ln| {
|
||||
.filter_map(|p_ln| {
|
||||
debug_assert!(p_ln.starts_with(PACK_PREFIX));
|
||||
let p = &p_ln[PACK_PREFIX.len()..];
|
||||
debug_assert!(PackageId::new(p).is_some());
|
||||
String::from(p)
|
||||
if PackageId::new(p).is_some() {
|
||||
Some(String::from(p))
|
||||
} else {
|
||||
warn!("skipping nonstandard package name: {p:?}");
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ pub fn request_builder(commands: &[&str], package: &str, user: Option<User>) ->
|
|||
// guarantee local to the sink instead of relying on each caller to sanitise.
|
||||
// Fail closed: emit no command for a malformed name rather than an injectable
|
||||
// device-shell string.
|
||||
if PackageId::new(package).is_some() {
|
||||
if PackageId::new(package).is_none() {
|
||||
error!("request_builder: refusing invalid package name: {package:?}");
|
||||
return Vec::new();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue