Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49877 - trunk/tools/jam/src
From: grafikrobot_at_[hidden]
Date: 2008-11-22 19:21:21


Author: grafik
Date: 2008-11-22 19:21:21 EST (Sat, 22 Nov 2008)
New Revision: 49877
URL: http://svn.boost.org/trac/boost/changeset/49877

Log:
Fix some possible overrun issues revealed by Fortify build. Thanks to Steven Robbins for pointing out the issues. (fixes #2527)
Text files modified:
   trunk/tools/jam/src/compile.c | 2 +-
   trunk/tools/jam/src/make1.c | 2 +-
   trunk/tools/jam/src/output.c | 3 +--
   trunk/tools/jam/src/variable.c | 18 ++++++++++++++++--
   4 files changed, 19 insertions(+), 6 deletions(-)

Modified: trunk/tools/jam/src/compile.c
==============================================================================
--- trunk/tools/jam/src/compile.c (original)
+++ trunk/tools/jam/src/compile.c 2008-11-22 19:21:21 EST (Sat, 22 Nov 2008)
@@ -1354,7 +1354,7 @@
         i = ( level + 1 ) * 2;
         while ( i > 35 )
         {
- printf( indent );
+ fputs( indent, stdout );
             i -= 35;
         }
 

Modified: trunk/tools/jam/src/make1.c
==============================================================================
--- trunk/tools/jam/src/make1.c (original)
+++ trunk/tools/jam/src/make1.c 2008-11-22 19:21:21 EST (Sat, 22 Nov 2008)
@@ -1017,7 +1017,7 @@
                 cmd = cmd_new( rule, list_copy( L0, nt ),
                     list_sublist( ns, start, chunk ),
                     list_new( L0, newstr( "%" ) ) );
- printf( cmd->buf );
+ fputs( cmd->buf, stdout );
                 exit( EXITBAD );
             }
         }

Modified: trunk/tools/jam/src/output.c
==============================================================================
--- trunk/tools/jam/src/output.c (original)
+++ trunk/tools/jam/src/output.c 2008-11-22 19:21:21 EST (Sat, 22 Nov 2008)
@@ -21,8 +21,7 @@
     while ( *data )
     {
         size_t len = strcspn(data,"\r");
- fwrite(data,len,1,io);
- data += len;
+ data += fwrite(data,1,len,io);
         if ( *data == '\r' ) ++data;
     }
 }

Modified: trunk/tools/jam/src/variable.c
==============================================================================
--- trunk/tools/jam/src/variable.c (original)
+++ trunk/tools/jam/src/variable.c 2008-11-22 19:21:21 EST (Sat, 22 Nov 2008)
@@ -441,8 +441,22 @@
         }
         else if ( output_0 < output_1 )
         {
- if ( out_file ) fwrite( output_0, output_1 - output_0, 1, out_file );
- if ( out_debug ) fwrite( output_0, output_1 - output_0, 1, stdout );
+ if ( out_file )
+ {
+ const char * output_n = output_0;
+ while ( output_n < output_1 )
+ {
+ output_n += fwrite( output_n, 1, output_1-output_n, out_file );
+ }
+ }
+ if ( out_debug )
+ {
+ const char * output_n = output_0;
+ while ( output_n < output_1 )
+ {
+ output_n += fwrite( output_n, 1, output_1-output_n, stdout );
+ }
+ }
         }
 
         in = output_1;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk