From 43d323332f4c7a074fffd3cdb31a7ce20f464fc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Klein?= <44199273+burninc0de@users.noreply.github.com> Date: Fri, 17 Jul 2026 00:35:15 +0300 Subject: [PATCH] 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. --- crates/uad-core/src/adb.rs | 12 ++++++++---- crates/uad-core/src/sync.rs | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/uad-core/src/adb.rs b/crates/uad-core/src/adb.rs index e7d223c..f2335e0 100644 --- a/crates/uad-core/src/adb.rs +++ b/crates/uad-core/src/adb.rs @@ -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() }) diff --git a/crates/uad-core/src/sync.rs b/crates/uad-core/src/sync.rs index 9bdd7cc..b4b912a 100644 --- a/crates/uad-core/src/sync.rs +++ b/crates/uad-core/src/sync.rs @@ -213,7 +213,7 @@ pub fn request_builder(commands: &[&str], package: &str, user: Option) -> // 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(); }