[rtems commit] tools/build/eolstrip.c: Use snprintf() to avoid potential buffer overflow
Joel Sherrill
joel at rtems.org
Tue Mar 14 17:02:21 UTC 2017
Module: rtems
Branch: master
Commit: c218d01d7a010f05878192a919cddccaf80394a0
Changeset: http://git.rtems.org/rtems/commit/?id=c218d01d7a010f05878192a919cddccaf80394a0
Author: Joel Sherrill <joel at rtems.org>
Date: Mon Mar 13 10:42:24 2017 -0500
tools/build/eolstrip.c: Use snprintf() to avoid potential buffer overflow
This was spotted by Coverity Scan.
---
tools/build/eolstrip.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tools/build/eolstrip.c b/tools/build/eolstrip.c
index e93b45e..091b06e 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)
More information about the vc
mailing list