workflow/status: use delay_for instead of frame counter
What changed, and why it matters
This commit simplifies how the BitBox02 hardware wallet shows short status messages (like 'success' or 'error' screens). Previously, the screen used a frame-counter inside the graphics rendering code to decide when to fire a callback and close itself. Now it simply waits a fixed 2-second delay. The change removes a callback mechanism that ran inside the rendering loop, which is a code-quality improvement but does not appear to fix an active security vulnerability.
Treat as a routine refactoring/cleanup. No security patch or incident response is indicated by the commit content alone. If reviewing for release, verify that the 2-second delay matches product expectations and that the removed callback was not relied upon by other workflows.
Security signals we found
Removal of callback/user_data from a UI component API reduces attack surface from callback invocation during rendering
Frame-counter timing replaced by explicit delay, making status-screen duration deterministic rather than frame-rate dependent
No evidence of buffer overflow, use-after-free, or privilege escalation in the diff
Evidence from the diff
The patch refactors status_create and the Rust status workflow. It removes the callback/user_data parameters from the C status component and the associated frame-counter logic in _render. The Rust side now pushes the status screen and awaits delay_for(Duration::from_millis(2000)) instead of awaiting an async signal from a closure. This eliminates a callback fired from the UI render path and replaces timing based on rendered frames with a real-time delay. No memory-safety bug, authentication bypass, or cryptographic issue is visible in the diff.
Changed components
src/rust/bitbox02-rust/src/workflow/status.rssrc/rust/bitbox02/src/ui/ui.rssrc/rust/bitbox02/src/ui/ui_stub.rssrc/rust/bitbox02/src/ui/ui_stub_c_unit_tests.rssrc/ui/components/status.csrc/ui/components/status.htest/unit-test/test_ui_components.cInspect captured patch +10 / −64
diff --git a/src/rust/bitbox02-rust/src/workflow/status.rs b/src/rust/bitbox02-rust/src/workflow/status.rs
index d5a38ec..4a5d69d 100644
--- a/src/rust/bitbox02-rust/src/workflow/status.rs
+++ b/src/rust/bitbox02-rust/src/workflow/status.rs
@@ -12,14 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-use crate::bb02_async::option_no_screensaver;
-use core::cell::RefCell;
+use bitbox02::delay::delay_for;
+use core::time::Duration;
pub async fn status(title: &str, status_success: bool) {
- let result = RefCell::new(None);
- let mut component = bitbox02::ui::status_create(title, status_success, || {
- *result.borrow_mut() = Some(());
- });
+ let mut component = bitbox02::ui::status_create(title, status_success);
component.screen_stack_push();
- option_no_screensaver(&result).await
+ delay_for(Duration::from_millis(2000)).await;
}
diff --git a/src/rust/bitbox02/src/ui/ui.rs b/src/rust/bitbox02/src/ui/ui.rs
index 904b506..7545319 100644
--- a/src/rust/bitbox02/src/ui/ui.rs
+++ b/src/rust/bitbox02/src/ui/ui.rs
@@ -166,27 +166,11 @@ pub fn screen_process() {
}
}
-pub fn status_create<'a, F>(text: &str, status_success: bool, callback: F) -> Component<'a>
-where
- // Callback must outlive component.
- F: FnMut() + 'a,
-{
- unsafe extern "C" fn c_callback<F2>(user_data: *mut c_void)
- where
- F2: FnMut(),
- {
- // The callback is dropped afterwards. This is safe because
- // this C callback is guaranteed to be called only once.
- let mut callback = unsafe { Box::from_raw(user_data as *mut F2) };
- callback();
- }
-
+pub fn status_create<'a>(text: &str, status_success: bool) -> Component<'a> {
let component = unsafe {
bitbox02_sys::status_create(
crate::util::str_to_cstr_vec(text).unwrap().as_ptr(), // copied in C
status_success,
- Some(c_callback::<F>),
- Box::into_raw(Box::new(callback)) as *mut _, // passed to c_callback as `user_data`.
)
};
Component {
diff --git a/src/rust/bitbox02/src/ui/ui_stub.rs b/src/rust/bitbox02/src/ui/ui_stub.rs
index 5b409c6..9166640 100644
--- a/src/rust/bitbox02/src/ui/ui_stub.rs
+++ b/src/rust/bitbox02/src/ui/ui_stub.rs
@@ -70,10 +70,7 @@ where
pub fn screen_process() {}
-pub fn status_create<'a, F>(_text: &str, _status_success: bool, _callback: F) -> Component<'a>
-where
- F: FnMut() + 'a,
-{
+pub fn status_create<'a>(_text: &str, _status_success: bool) -> Component<'a> {
panic!("not used");
}
diff --git a/src/rust/bitbox02/src/ui/ui_stub_c_unit_tests.rs b/src/rust/bitbox02/src/ui/ui_stub_c_unit_tests.rs
index 69a4b22..802f12e 100644
--- a/src/rust/bitbox02/src/ui/ui_stub_c_unit_tests.rs
+++ b/src/rust/bitbox02/src/ui/ui_stub_c_unit_tests.rs
@@ -85,15 +85,11 @@ where
pub fn screen_process() {}
-pub fn status_create<'a, F>(text: &str, _status_success: bool, mut callback: F) -> Component<'a>
-where
- F: FnMut() + 'a,
-{
+pub fn status_create<'a>(text: &str, _status_success: bool) -> Component<'a> {
crate::print_stdout(&format!(
"STATUS SCREEN START\nTITLE: {}\nSTATUS SCREEN END\n",
text,
));
- callback();
Component {
is_pushed: false,
_p: PhantomData,
diff --git a/src/ui/components/status.c b/src/ui/components/status.c
index 8840567..b9178f3 100644
--- a/src/ui/components/status.c
+++ b/src/ui/components/status.c
@@ -21,17 +21,8 @@
#include <stdbool.h>
#include <string.h>
-#if defined(TESTING)
- #define STATUS_DEFAULT_DELAY 100 // counts
-#else
- #define STATUS_DEFAULT_DELAY 500 // counts
-#endif
-
typedef struct {
bool status;
- int counter;
- void (*callback)(void* user_data);
- void* user_data;
} status_data_t;
static void _render(component_t* component)
@@ -43,14 +34,6 @@ static void _render(component_t* component)
} else {
image_cross(SCREEN_WIDTH / 6 * 5, SCREEN_HEIGHT / 2 - height / 2, height);
}
- if (data->callback != NULL) {
- if (data->counter == STATUS_DEFAULT_DELAY) {
- data->callback(data->user_data);
- data->callback = NULL;
- data->counter = 0;
- }
- data->counter++;
- }
ui_util_component_render_subcomponents(component);
}
@@ -64,11 +47,7 @@ static const component_functions_t _component_functions = {
/********************************** Create Instance **********************************/
-component_t* status_create(
- const char* text,
- bool status_success,
- void (*callback)(void* user_data),
- void* user_data)
+component_t* status_create(const char* text, bool status_success)
{
component_t* status = malloc(sizeof(component_t));
if (!status) {
@@ -82,8 +61,6 @@ component_t* status_create(
memset(status, 0, sizeof(component_t));
data->status = status_success;
- data->callback = callback;
- data->user_data = user_data;
status->data = data;
status->f = &_component_functions;
status->dimension.width = SCREEN_WIDTH;
diff --git a/src/ui/components/status.h b/src/ui/components/status.h
index 9bb00e6..a76beb4 100644
--- a/src/ui/components/status.h
+++ b/src/ui/components/status.h
@@ -24,12 +24,7 @@
* Creates a status component with a given text. Calls the callback after delay.
* @param[IN] text The text of the status screen.
* @param[IN] status_success If true, indicates a success. Otherwise, false.
- * @param[IN] callback The callback that is called after <delay> time. Will be called at most once.
*/
-component_t* status_create(
- const char* text,
- bool status_success,
- void (*callback)(void* user_data),
- void* user_data);
+component_t* status_create(const char* text, bool status_success);
#endif
diff --git a/test/unit-test/test_ui_components.c b/test/unit-test/test_ui_components.c
index a3494f7..1059895 100644
--- a/test/unit-test/test_ui_components.c
+++ b/test/unit-test/test_ui_components.c
@@ -152,7 +152,7 @@ static void test_ui_components_keyboard_switch(void** state)
static void test_ui_components_status(void** state)
{
- component_t* status = status_create("Password created", true, NULL, NULL);
+ component_t* status = status_create("Password created", true);
assert_non_null(status);
assert_ui_component_functions(status);
status->f->cleanup(status);
Why this scored 18/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.