diff options
| author | Glenn Smith <glenn@vector35.com> | 2023-08-07 23:30:52 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2023-08-07 23:31:12 -0400 |
| commit | 9772037768221179318765893565951370277480 (patch) | |
| tree | 289baf433dfdd334642f2204b18e0b6de23dac80 /rust/src/logger.rs | |
| parent | de088beee82a68d070f4f92602d71ab29aee5d55 (diff) | |
[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.
Diffstat (limited to 'rust/src/logger.rs')
| -rw-r--r-- | rust/src/logger.rs | 10 |
1 files changed, 9 insertions, 1 deletions
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(), + ); } }; } |
