Fix crash when deleting recordings

Due to a refactor in https://github.com/EFForg/rayhunter/pull/350, we
had to move more into the shared codepath of StopRecording. The todo!()
used to be unreachable when it was just in the stop-recording endpoint.

Fix #367
This commit is contained in:
Markus Unterwaditzer
2025-06-05 15:45:58 +02:00
committed by Cooper Quintin
parent f2b722ad5f
commit 8d8d2bd8ec
2 changed files with 13 additions and 29 deletions
+8 -11
View File
@@ -72,17 +72,14 @@ pub fn run_diag_read_thread(
}, },
Some(DiagDeviceCtrlMessage::StopRecording) => { Some(DiagDeviceCtrlMessage::StopRecording) => {
let mut qmdl_store = qmdl_store_lock.write().await; let mut qmdl_store = qmdl_store_lock.write().await;
match qmdl_store.get_current_entry() { if let Some((_, entry)) = qmdl_store.get_current_entry() {
Some((_, entry)) => { if let Err(e) = analysis_sender
if let Err(e) = analysis_sender .send(AnalysisCtrlMessage::RecordingFinished(
.send(AnalysisCtrlMessage::RecordingFinished( entry.name.to_string(),
entry.name.to_string(), ))
)) .await {
.await { warn!("couldn't send analysis message: {}", e);
warn!("couldn't send analysis message: {}", e); }
}
}
None => todo!(),
} }
if let Err(e) = qmdl_store.close_current_entry().await { if let Err(e) = qmdl_store.close_current_entry().await {
error!("couldn't close current entry: {}", e); error!("couldn't close current entry: {}", e);
+5 -18
View File
@@ -81,17 +81,10 @@ async fn force_debug_mode() -> Result<ADBUSBDevice> {
Ok(adb_device) Ok(adb_device)
} }
async fn setup_rootshell( async fn setup_rootshell(adb_device: &mut ADBUSBDevice) -> Result<()> {
adb_device: &mut ADBUSBDevice,
) -> Result<()> {
let rootshell_bin = include_bytes!(env!("FILE_ROOTSHELL")); let rootshell_bin = include_bytes!(env!("FILE_ROOTSHELL"));
install_file( install_file(adb_device, "/bin/rootshell", rootshell_bin).await?;
adb_device,
"/bin/rootshell",
rootshell_bin,
)
.await?;
tokio::time::sleep(Duration::from_secs(1)).await; tokio::time::sleep(Duration::from_secs(1)).await;
adb_at_syscmd(adb_device, "chown root /bin/rootshell").await?; adb_at_syscmd(adb_device, "chown root /bin/rootshell").await?;
tokio::time::sleep(Duration::from_secs(1)).await; tokio::time::sleep(Duration::from_secs(1)).await;
@@ -103,9 +96,7 @@ async fn setup_rootshell(
Ok(()) Ok(())
} }
async fn setup_rayhunter( async fn setup_rayhunter(mut adb_device: ADBUSBDevice) -> Result<ADBUSBDevice> {
mut adb_device: ADBUSBDevice,
) -> Result<ADBUSBDevice> {
let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON_ORBIC")); let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON_ORBIC"));
adb_at_syscmd(&mut adb_device, "mkdir -p /data/rayhunter").await?; adb_at_syscmd(&mut adb_device, "mkdir -p /data/rayhunter").await?;
@@ -169,11 +160,7 @@ async fn test_rayhunter(adb_device: &mut ADBUSBDevice) -> Result<()> {
bail!("timeout reached! failed to reach rayhunter, something went wrong :(") bail!("timeout reached! failed to reach rayhunter, something went wrong :(")
} }
async fn install_file( async fn install_file(adb_device: &mut ADBUSBDevice, dest: &str, payload: &[u8]) -> Result<()> {
adb_device: &mut ADBUSBDevice,
dest: &str,
payload: &[u8],
) -> Result<()> {
const MAX_FAILURES: u32 = 5; const MAX_FAILURES: u32 = 5;
let mut failures = 0; let mut failures = 0;
loop { loop {
@@ -250,7 +237,7 @@ async fn get_adb() -> Result<ADBUSBDevice> {
Err(RustADBError::IOError(e)) if e.kind() == ErrorKind::ResourceBusy => { Err(RustADBError::IOError(e)) if e.kind() == ErrorKind::ResourceBusy => {
bail!(ORBIC_BUSY); bail!(ORBIC_BUSY);
} }
#[cfg(any(target_os = "macos", target_os="windows"))] #[cfg(any(target_os = "macos", target_os = "windows"))]
Err(RustADBError::IOError(e)) if e.kind() == ErrorKind::PermissionDenied => { Err(RustADBError::IOError(e)) if e.kind() == ErrorKind::PermissionDenied => {
bail!(ORBIC_BUSY_MAC); bail!(ORBIC_BUSY_MAC);
} }