summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Sherrill <joel@rtems.org>2017-03-13 10:42:24 -0500
committerJoel Sherrill <joel@rtems.org>2017-03-14 12:02:09 -0500
commitc218d01d7a010f05878192a919cddccaf80394a0 (patch)
tree2a93037b24c2e00bf86af4efb33a1a096e32e9b3
parentlibchip/serial/mc68681.c: Add error check (diff)
downloadrtems-c218d01d7a010f05878192a919cddccaf80394a0.tar.bz2
tools/build/eolstrip.c: Use snprintf() to avoid potential buffer overflow
This was spotted by Coverity Scan.
-rw-r--r--tools/build/eolstrip.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/build/eolstrip.c b/tools/build/eolstrip.c
index e93b45e906..091b06e47e 100644
--- a/tools/build/eolstrip.c
+++ b/tools/build/eolstrip.c
@@ -171,7 +171,9 @@ process(char *arg)
error( ERR_ERRNO | ERR_FATAL, "Unable to open file (%s)\n", arg );
if ( !test_only ) {
- sprintf( outname, "%s.eoltmp", arg );
+ length = snprintf( outname, BUFFER_SIZE, "%s.eoltmp", arg );
+ if (length >= BUFFER_SIZE)
+ error( ERR_ERRNO | ERR_FATAL, "Tmp file name too long\n" );
out = fopen( outname, "w" );
if (!out)