From b108e8cd87dcfa4e5972870991d028de00ab8343 Mon Sep 17 00:00:00 2001 From: David Drysdale Date: Mon, 18 Dec 2023 17:22:15 +0000 Subject: [PATCH] authgraph: cope with LocalTa being dropped When a LocalTa instance is used in a fuzzer, it gets dropped at the end of processing each fuzz input. This makes the `mpsc::channel`s fail, so update to cope with this. Bug: 316075932 Test: run fuzzer on Cuttlefish Change-Id: I069f441013e269f652cbe1ff3053606f9bcb2dfd --- security/authgraph/default/src/lib.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/security/authgraph/default/src/lib.rs b/security/authgraph/default/src/lib.rs index 1f851b28e8..1d6ffb3108 100644 --- a/security/authgraph/default/src/lib.rs +++ b/security/authgraph/default/src/lib.rs @@ -22,6 +22,7 @@ use authgraph_core::{ ta::{AuthGraphTa, Role}, }; use authgraph_hal::channel::SerializedChannel; +use log::error; use std::cell::RefCell; use std::rc::Rc; use std::sync::{mpsc, Mutex}; @@ -57,10 +58,23 @@ impl LocalTa { ); // Loop forever processing request messages. loop { - let req_data: Vec = in_rx.recv().expect("failed to receive next req"); + let req_data: Vec = match in_rx.recv() { + Ok(data) => data, + Err(_) => { + error!("local TA failed to receive request!"); + break; + } + }; let rsp_data = ta.process(&req_data); - out_tx.send(rsp_data).expect("failed to send out rsp"); + match out_tx.send(rsp_data) { + Ok(_) => {} + Err(_) => { + error!("local TA failed to send out response"); + break; + } + } } + error!("local TA terminating!"); }); Ok(Self { channels: Mutex::new(Channels { in_tx, out_rx }),