Ticket #2527: jam-hardening.patch

File jam-hardening.patch, 2.5 KB (added by Steven Robbins <smr@…>, 14 years ago)
  • tools/jam/src/compile.c

    From Kees Cook, Debian BTS #505734
    
    old new  
    14041404      i = (level+1)*2;
    14051405      while ( i > 35 )
    14061406      {
    1407         printf( indent );
     1407        printf( "%s", indent );
    14081408        i -= 35;
    14091409      }
    14101410
  • tools/jam/src/make1.c

    old new  
    10181018                        list_sublist( ns, start, chunk ),
    10191019                        list_new( L0, newstr( "%" ) ) );
    10201020
    1021                     printf( cmd->buf );
     1021                    printf( "%s", cmd->buf );
    10221022               
    10231023                    exit( EXITBAD );
    10241024                }
  • tools/jam/src/output.c

    old new  
    2020    while ( *data )
    2121    {
    2222        size_t len = strcspn(data,"\r");
    23         fwrite(data,len,1,io);
     23        do { if (fwrite(data,len,1,io)) {} } while (0);
    2424        data += len;
    2525        if ( *data == '\r' ) ++data;
    2626    }
  • tools/jam/src/variable.c

    old new  
    416416        }
    417417        if ( output_0 < output_1 )
    418418        {
    419             if ( out_file ) fwrite(output_0,output_1-output_0,1,out_file);
    420             if ( out_debug ) fwrite(output_0,output_1-output_0,1,stdout);
     419            if ( out_file ) {
     420                if ( fwrite(output_0,output_1-output_0,1,out_file) < 1 ) {
     421                    printf( "failed to write output file!\n" );
     422                    exit( EXITBAD );
     423                }
     424            }
     425            if ( out_debug ) {
     426                if ( fwrite(output_0,output_1-output_0,1,stdout) < 1 ) {
     427                    printf( "failed to write output to stdout!\n" );
     428                    exit( EXITBAD );
     429                }
     430            }
    421431        }
    422432        output_0 = output_1;
    423433
     
    457467        }
    458468        else if ( output_0 < output_1 )
    459469        {
    460             if ( out_file ) fwrite(output_0,output_1-output_0,1,out_file);
    461             if ( out_debug ) fwrite(output_0,output_1-output_0,1,stdout);
     470            if ( out_file ) {
     471                if ( fwrite(output_0,output_1-output_0,1,out_file) < 1 ) {
     472                    printf( "failed to write output file!\n" );
     473                    exit( EXITBAD );
     474                }
     475            }
     476            if ( out_debug ) {
     477                if ( fwrite(output_0,output_1-output_0,1,stdout) < 1 ) {
     478                    printf( "failed to write output to stdout!\n" );
     479                    exit( EXITBAD );
     480                }
     481            }
    462482        }
    463483       
    464484        in = output_1;