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( '-' );