@@ -528,7 +528,7 @@ int STEPfile::ReadData1( istream & in ) {
528528 } // end while loop
529529
530530 if ( _entsNotCreated ) {
531- sprintf ( buf,
531+ snprintf ( buf, sizeof (buf) ,
532532 " STEPfile Reading File: Unable to create %d instances.\n\t In first pass through DATA section. Check for invalid entity types.\n " ,
533533 _entsNotCreated );
534534 _error.AppendToUserMsg ( buf );
@@ -647,7 +647,7 @@ int STEPfile::ReadData2( istream & in, bool useTechCor ) {
647647 } // end while loop
648648
649649 if ( _entsInvalid ) {
650- sprintf ( buf,
650+ snprintf ( buf, sizeof (buf) ,
651651 " %s \n\t Total instances: %d \n\t Invalid instances: %d \n\t Incomplete instances (includes invalid instances): %d \n\t %s: %d.\n " ,
652652 " Second pass complete - instance summary:" , total_instances,
653653 _entsInvalid, _entsIncomplete, " Warnings" ,
@@ -1321,7 +1321,7 @@ SDAI_Application_instance * STEPfile::ReadInstance( istream & in, ostream & out,
13211321 }
13221322 } else {
13231323 if ( node->CurrState () == completeSE ) {
1324- sprintf ( errbuf, " WARNING in WORKING FILE: changing instance #%d state from completeSE to incompleteSE.\n " , fileid );
1324+ snprintf ( errbuf, sizeof (errbuf) , " WARNING in WORKING FILE: changing instance #%d state from completeSE to incompleteSE.\n " , fileid );
13251325 _error.AppendToUserMsg ( errbuf );
13261326 if ( _fileType != WORKING_SESSION ) {
13271327 node->ChangeState ( incompleteSE );
@@ -1643,7 +1643,7 @@ Severity STEPfile::AppendFile( istream * in, bool useTechCor ) {
16431643 }
16441644 SetFileType ( WORKING_SESSION );
16451645 } else {
1646- sprintf ( errbuf,
1646+ snprintf ( errbuf, sizeof (errbuf) ,
16471647 " Faulty input at beginning of file. \" ISO-10303-21;\" or"
16481648 " \" STEP_WORKING_SESSION;\" expected. File not read: %s\n " ,
16491649 ( ( FileName ().compare ( " -" ) == 0 ) ? " standard input" : FileName ().c_str () ) );
@@ -1658,14 +1658,14 @@ Severity STEPfile::AppendFile( istream * in, bool useTechCor ) {
16581658 rval = ReadHeader ( *in );
16591659 cout << " \n HEADER read:" ;
16601660 if ( rval < SEVERITY_WARNING ) {
1661- sprintf ( errbuf,
1661+ snprintf ( errbuf, sizeof (errbuf) ,
16621662 " Error: non-recoverable error in reading header section. "
16631663 " There were %d errors encountered. Rest of file is ignored.\n " ,
16641664 _errorCount );
16651665 _error.AppendToUserMsg ( errbuf );
16661666 return rval;
16671667 } else if ( rval != SEVERITY_NULL ) {
1668- sprintf ( errbuf, " %d ERRORS\t %d WARNINGS\n\n " ,
1668+ snprintf ( errbuf, sizeof (errbuf) , " %d ERRORS\t %d WARNINGS\n\n " ,
16691669 _errorCount, _warningCount );
16701670 cout << errbuf;
16711671 } else {
@@ -1683,7 +1683,7 @@ Severity STEPfile::AppendFile( istream * in, bool useTechCor ) {
16831683
16841684 cout << " \n FIRST PASS complete: " << total_insts
16851685 << " instances created.\n " ;
1686- sprintf ( errbuf,
1686+ snprintf ( errbuf, sizeof (errbuf) ,
16871687 " %d ERRORS\t %d WARNINGS\n\n " ,
16881688 _errorCount, _warningCount );
16891689 cout << errbuf;
@@ -1727,7 +1727,7 @@ Severity STEPfile::AppendFile( istream * in, bool useTechCor ) {
17271727 // check for "ENDSEC;"
17281728 ReadTokenSeparator ( *in2 );
17291729 if ( total_insts != valid_insts ) {
1730- sprintf ( errbuf, " %d invalid instances in file: %s\n " ,
1730+ snprintf ( errbuf, sizeof (errbuf) , " %d invalid instances in file: %s\n " ,
17311731 total_insts - valid_insts, ( ( FileName ().compare ( " -" ) == 0 ) ? " standard input" : FileName ().c_str () ) );
17321732 _error.AppendToUserMsg ( errbuf );
17331733 CloseInputFile ( in2 );
@@ -1736,7 +1736,7 @@ Severity STEPfile::AppendFile( istream * in, bool useTechCor ) {
17361736
17371737 cout << " \n SECOND PASS complete: " << valid_insts
17381738 << " instances valid.\n " ;
1739- sprintf ( errbuf,
1739+ snprintf ( errbuf, sizeof (errbuf) ,
17401740 " %d ERRORS\t %d WARNINGS\n\n " ,
17411741 _errorCount, _warningCount );
17421742 _error.AppendToUserMsg ( errbuf );
0 commit comments