Skip to content

Commit d2f1187

Browse files
trofiKaian
authored andcommitted
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: curses/ui_msg_diff.c: In function 'msg_diff_draw_message': curses/ui_msg_diff.c:190:5: error: format not a string literal and no format arguments [-Werror=format-security] 190 | mvwprintw(win, 0, 0, sip_get_msg_header(msg, header)); | ^~~~~~~~~ Let's wrap all the missing places with "%s" format.
1 parent 35a978e commit d2f1187

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/curses/ui_call_flow.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,9 @@ call_flow_draw_message(ui_t *ui, call_flow_arrow_t *arrow, int cline)
571571
media->address.port,
572572
media_get_prefered_format(media));
573573
if (arrow->dir == CF_ARROW_SPIRAL) {
574-
mvwprintw(flow_win, cline + 1, startpos + 5, mediastr);
574+
mvwprintw(flow_win, cline + 1, startpos + 5, "%s", mediastr);
575575
} else {
576-
mvwprintw(flow_win, cline + 1, startpos + distance / 2 - strlen(mediastr) / 2 + 2, mediastr);
576+
mvwprintw(flow_win, cline + 1, startpos + distance / 2 - strlen(mediastr) / 2 + 2, "%s", mediastr);
577577
}
578578
cline++;
579579
aline++;

src/curses/ui_manager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ dialog_confirm(const char *title, const char *text, const char *options)
665665
curs = curs_set(0);
666666

667667
// Set the window title
668-
mvwprintw(dialog_win, 1, (width - strlen(title)) / 2, title);
668+
mvwprintw(dialog_win, 1, (width - strlen(title)) / 2, "%s", title);
669669

670670
// Write border and boxes around the window
671671
wattron(dialog_win, COLOR_PAIR(CP_BLUE_ON_DEF));

src/curses/ui_msg_diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ msg_diff_draw_message(WINDOW *win, sip_msg_t *msg, char *highlight)
187187
getmaxyx(win, height, width);
188188

189189
wattron(win, A_BOLD);
190-
mvwprintw(win, 0, 0, sip_get_msg_header(msg, header));
190+
mvwprintw(win, 0, 0, "%s", sip_get_msg_header(msg, header));
191191
wattroff(win, A_BOLD);
192192

193193
// Print msg payload

0 commit comments

Comments
 (0)