From 9772037768221179318765893565951370277480 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Mon, 7 Aug 2023 23:30:52 -0400 Subject: [Rust API] Fix format string bug in BNLog You would think we, a security company, would not have format string vulns in $current_year. Yet, here we are. --- rust/src/logger.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'rust/src') diff --git a/rust/src/logger.rs b/rust/src/logger.rs index 7df87c93..8651eec3 100644 --- a/rust/src/logger.rs +++ b/rust/src/logger.rs @@ -59,8 +59,16 @@ impl log::Log for Logger { }; if let Ok(msg) = CString::new(format!("{}", record.args())) { + let percent_s = CString::new("%s").expect("'%s' has no null bytes"); unsafe { - BNLog(0, level, std::ptr::null(), 0, msg.as_ptr()); + BNLog( + 0, + level, + std::ptr::null(), + 0, + percent_s.as_ptr(), + msg.as_ptr(), + ); } }; } -- cgit v1.3.1