Repository: jeaye/ncurses-rs (language: rust)

Issue:
`printw` should not be exposed.
It's very difficult / impossible to use this function from rust without introducing a format string vulnerability into your code (which can be used to trigger arbitrary code execution).

If you must expose something like it, have it just call addstr or mark it as unsafe (and deprecate it in both cases, IMO).

See also: #149 and #125.


Discussion / hints:

Fix patch:
diff --git a/src/lib.rs b/src/lib.rs
index fc8a11b4..f50793f1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1103,6 +1103,7 @@ pub fn prefresh(pad: WINDOW, pmin_row: i32, pmin_col: i32, smin_row: i32, smin_c
 { unsafe { ll::prefresh(pad, pmin_row, pmin_col, smin_row, smin_col, smax_row, smax_col) } }
 
 
+#[deprecated(since = "5.98.0", note = "printw can segfault when printing string that contains % sign. Use addstr instead")]
 pub fn printw(s: &str) -> i32
 { unsafe { ll::printw(s.to_c_str().as_ptr()) } }
 


Test patch: