Fix coverity reported strcat/strcpy potential overflows

This commit is contained in:
unknown 2015-08-10 10:17:22 +02:00 committed by jean-pierre charras
parent 140d17bf82
commit 2330b13864
3 changed files with 7 additions and 3 deletions

View File

@ -97,7 +97,7 @@ static int okRevision( const std::string& aField )
if( aField.size() >= 4 )
{
strcpy( rev, "x/" );
strcat( rev, aField.c_str() );
strncat( rev, aField.c_str(), sizeof(rev)-strlen(rev)-1 );
if( EndsWithRev( rev, rev + strlen(rev), '/' ) == rev+2 )
return -1; // success

View File

@ -597,7 +597,10 @@ bool GERBER_IMAGE::ExecuteRS274XCommand( int command,
ReportMessage( _( "Too many include files!!" ) );
break;
}
strcpy( line, text );
strncpy( line, text, sizeof(line)-1 );
line[sizeof(line)-1] = '\0';
strtok( line, "*%%\n\r" );
m_FilesList[m_FilesPtr] = m_Current_File;

View File

@ -108,7 +108,8 @@ COMPONENT* LEGACY_NETLIST_READER::loadComponent( char* aText )
wxString name; // the name of component that was placed in the schematic
char line[1024];
strcpy( line, aText );
strncpy( line, aText, sizeof(line)-1 );
line[sizeof(line)-1] = '\0';
value = wxT( "~" );