From 760682824cdbb328af616ff43bf822ade23924f7 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Thu, 18 Nov 2021 10:28:13 +0000 Subject: [PATCH] pacvim: always use "%s"-style format for printf()-style functions `ncuses-6.3` added printf-style function attributes and now makes it easier to catch cases when user input is used in palce of format string when built with CFLAGS=-Werror=format-security: src/helperFns.cpp:103:17: error: format not a string literal and no format arguments [-Werror=format-security] 103 | mvprintw(TOP+5, 0, (x).c_str()); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ Let's wrap all the missing places with "%s" format. --- src/game.cpp | 2 +- src/helperFns.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/game.cpp b/src/game.cpp index 94f148a..deb1152 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -234,7 +234,7 @@ void levelMessage() { string msg = ss.str(); // print + pause - printw(msg.c_str()); + printw("%s", msg.c_str()); refresh(); usleep(1500000); diff --git a/src/helperFns.cpp b/src/helperFns.cpp index 50f5c2d..f4466aa 100644 --- a/src/helperFns.cpp +++ b/src/helperFns.cpp @@ -100,14 +100,14 @@ void printAtBottomChar(char msg) { //mtx.lock(); std::string x; x += msg; - mvprintw(TOP+5, 0, (x).c_str()); + mvprintw(TOP+5, 0, "%s", (x).c_str()); //mtx.unlock(); } void printAtBottom(std::string msg) { //mtx.lock(); int x, y; getyx(stdscr, y, x); - mvprintw(TOP+1, 1, msg.c_str()); + mvprintw(TOP+1, 1, "%s", msg.c_str()); mvinch(y,x); move(y,x);