From 8c5d69aab4f9c8b445033c0471d445c1518d7243 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 14 Feb 2009 04:37:25 +0000 Subject: [PATCH] convert printf(buffer) to puts(buffer) to avoid security issues/warnings git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1433 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 5 +++++ jtag/src/cmd/print.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index b7a00aa6..95549af6 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -4,6 +4,11 @@ prefix to all local variables named "exit" to avoid shadowing the system exit() function. + * src/cmd/print.c (cmd_print_run): Use puts() to display the formatted buffer + rather than printf() to avoid security issues with dynamically generated + format strings, and to avoid warnings generated by such compilers: + print.c:111: warning: format not a string literal and no format arguments + 2009-02-11 Arnim Laeuger * src/bsdl/bsdl_sem.c: return proper error code to upper level diff --git a/jtag/src/cmd/print.c b/jtag/src/cmd/print.c index 9d8a8fb2..5b88387a 100644 --- a/jtag/src/cmd/print.c +++ b/jtag/src/cmd/print.c @@ -95,7 +95,7 @@ cmd_print_run( chain_t *chain, char *params[] ) part_t *part; instruction *inst; - snprintf( format, 128, _(" Active %%-%ds %%-%ds\n"), + snprintf( format, 128, _(" Active %%-%ds %%-%ds"), MAXLEN_INSTRUCTION, MAXLEN_DATA_REGISTER ); #if HAVE_SWPRINTF if (mbstowcs( wformat, format, 128 ) == -1) @@ -108,7 +108,7 @@ cmd_print_run( chain_t *chain, char *params[] ) if (mbstowcs( wheader, header, 128 ) == -1) printf( _("(%d) String conversion failed!\n"), __LINE__ ); #endif /* HAVE_SWPRINTF */ - printf( header ); + puts( header ); for (i = 0; i < wcslen( wheader ); i++ ) putchar( '-' ); @@ -130,7 +130,7 @@ cmd_print_run( chain_t *chain, char *params[] ) } if (noheader == 0) { - snprintf( format, 128, _(" No. %%-%ds %%-%ds %%-%ds %%-%ds %%-%ds\n"), MAXLEN_MANUFACTURER, MAXLEN_PART, MAXLEN_STEPPING, + snprintf( format, 128, _(" No. %%-%ds %%-%ds %%-%ds %%-%ds %%-%ds"), MAXLEN_MANUFACTURER, MAXLEN_PART, MAXLEN_STEPPING, MAXLEN_INSTRUCTION, MAXLEN_DATA_REGISTER ); #if HAVE_SWPRINTF if (mbstowcs( wformat, format, 128 ) == -1) @@ -143,7 +143,7 @@ cmd_print_run( chain_t *chain, char *params[] ) if (mbstowcs( wheader, header, 128 ) == -1) printf( _("(%d) String conversion failed!\n"), __LINE__ ); #endif /* HAVE_SWPRINTF */ - printf( header ); + puts( header ); for (i = 0; i < wcslen( wheader ); i++ ) putchar( '-' );