From 33434d49fb4ad287651f8b1ebc0a281995c6983d Mon Sep 17 00:00:00 2001 From: Matthias Jurenz Date: Mon, 18 Aug 2008 14:19:30 +0000 Subject: [PATCH] Fixed Coverity warnings CIDs: 1105 This commit was SVN r19342. --- ompi/contrib/vt/vt/tools/vtunify/vt_unify.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ompi/contrib/vt/vt/tools/vtunify/vt_unify.cc b/ompi/contrib/vt/vt/tools/vtunify/vt_unify.cc index 074f0d8bfd..9790fa44e2 100644 --- a/ompi/contrib/vt/vt/tools/vtunify/vt_unify.cc +++ b/ompi/contrib/vt/vt/tools/vtunify/vt_unify.cc @@ -629,8 +629,10 @@ cleanUp() if( access( filename1, F_OK ) != 0 ) { + assert( strlen( filename1 ) + 2 + 1 < sizeof( filename1 ) - 1 ); + // file not found, try '.z' suffix - strcat( filename1, ".z" ); + strncat( filename1, ".z", 2 ); } if( remove( filename1 ) == 0 ) @@ -659,9 +661,12 @@ cleanUp() if( access( filename1, F_OK ) != 0 ) { + assert( strlen( filename1 ) + 2 + 1 < sizeof( filename1 ) - 1 ); + assert( strlen( filename2 ) + 2 + 1 < sizeof( filename2 ) - 1 ); + // file not found, try '.z' suffix - strcat( filename1, ".z" ); - strcat( filename2, ".z" ); + strncat( filename1, ".z", 2 ); + strncat( filename2, ".z", 2 ); } if( rename( filename1, filename2 ) != 0 ) @@ -717,9 +722,12 @@ cleanUp() if( access( filename1, F_OK ) != 0 ) { + if( strlen( filename1 ) + 2 + 1 < sizeof( filename1 ) - 1 ); + if( strlen( filename2 ) + 2 + 1 < sizeof( filename2 ) - 1 ); + // file not found, try '.z' suffix - strcat( filename1, ".z" ); - strcat( filename2, ".z" ); + strncat( filename1, ".z", 2 ); + strncat( filename2, ".z", 2 ); } if( rename( filename1, filename2 ) == 0 )