Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Buffer Overrun  at trcfile.c:2631

Categories: LANG.MEM.BO CWE:120 CWE:121 CWE:122 CWE:126
Warning ID: 2894.2962
Similar Warnings: 2894.2960
Procedure: trc_read_trace_event
Trace: View
Modified: Wed Sep 2 12:52:05 2009   show details
 
Priority: None
State: None
Finding: None
Owner: None
  edit properties

Legend [ X ]
Warning Location
Contributes
Parse Error
Other Warning
Two or More Loop Iterations
On Execution Path
Comment
Macro
Preprocessor
Include
Keyword
Preprocessed Away

Source  |  Language: C Hide Legend     
ProblemLineSource
   /u1/paul/SATE/2010/c/pvm/pvm3/tracer/trcfile.c
   Enter trc_read_trace_event
 2421 trc_read_trace_event( ID, eof ) 
 2422 TRC_ID ID;
 2423 int *eof;
 2424 {
 2425         TRC_TEVDESC TD;
 2426  
 2427         char tmp[4096];
 2428         char c;
 2429  
 2430         int entry_exit;
 2431         int dummy;
 2432         int index;
 2433         int code;
 2434         int flag;
 2435         int eid;
 2436         int ee;
 2437         int i;
 2438  
 2439         *eof = TRC_FALSE;
 2440  
 2441         if ( ID->trace_in == NULL )
 2442                 return( TRC_FALSE );
 2443  
 2444         while ( TRC_TRUE )
 2445         {
 2446                 c = getc( ID->trace_in );
 2447  
 2448                 if ( c != (char) EOF )
 2449                 {
 2450                         switch ( c ) 
 2451                         {
 2452                                 /* Record Descriptor Packet */ 
 2453  
 2454                                 case '#': 
 2455                                 {
 2456                                         /* Get event ID */ 
 2457  
 2458                                         flag = fscanf( ID->trace_in, "%d", &code );
 2459  
 2460                                         if ( flag != 1 )
 2461                                         {
 2462                                                 printf( "Error Reading Event ID\n" );
 2463  
 2464                                                 return( TRC_FALSE );
 2465                                         }
 2466  
 2467                                         /* Get event name */ 
 2468  
 2469                                         if ( !trc_find_event_str( ID, "\"" ) )
 2470                                                 return( TRC_FALSE );
 2471  
 2472                                         i = 0;
 2473  
 2474                                         while ( (c = getc( ID->trace_in )) != (char) EOF 
 2475                                                 && c != '"' && c != '(' )
 2476                                         {
 2477                                                 tmp[i++] = c;   /* Buffer Overrun (ID: 2893.2959) */
 2478                                         }
 2479  
 2480                                         TRC_CKEOF( c, "EOF Reading Event Descriptor Name\n",
 2481                                                 return( TRC_FALSE ) );
 2482  
 2483                                         tmp[i] = '\0';   /* Buffer Overrun (ID: 2894.2960) */
 2484  
 2485                                         /* PVM 3.4 Trace */ 
 2486  
 2487                                         if ( c == '(' )
 2488                                         {
 2489                                                 /* Decode event ID */ 
 2490  
 2491                                                 index = ( code / 1000 ) - 1;
 2492  
 2493                                                 eid = ( code - ((index + 1) * 1000) ) / 2;
 2494  
 2495                                                 ee = code - ((index + 1) * 1000) - (2 * eid);
 2496  
 2497                                                 /* Read in entry/exit or index value */ 
 2498  
 2499                                                 flag = fscanf( ID->trace_in, "%d", &dummy );
 2500  
 2501                                                 if ( flag != 1 )
 2502                                                 {
 2503                                                         printf( "Error Reading Event Index\n" );
 2504  
 2505                                                         return( TRC_FALSE );
 2506                                                 }
 2507  
 2508                                                 /* Read in next char for parsing context */ 
 2509  
 2510                                                 c = getc( ID->trace_in );
 2511  
 2512                                                 TRC_CKEOF( c, "EOF Reading Event Descriptor\n",
 2513                                                         return( TRC_FALSE ) );
 2514  
 2515                                                 if ( c == '.' )
 2516                                                 {
 2517                                                         if ( ee != dummy )
 2518                                                         {
 2519                                                                 printf( "Warning:  " );
 2520                                                                 printf( "Entry/Exit Mismatch  " );
 2521                                                                 printf( "%d != %d\n", ee, dummy );
 2522                                                         }
 2523  
 2524                                                         entry_exit = TRC_IGNORE_TEV;
 2525  
 2526                                                         if ( dummy == 0 )
 2527                                                                 entry_exit = TRC_ENTRY_TEV;
 2528  
 2529                                                         else if ( dummy == 1 )
 2530                                                                 entry_exit = TRC_EXIT_TEV;
 2531  
 2532                                                         flag = fscanf( ID->trace_in, "%d", &dummy );
 2533  
 2534                                                         if ( flag != 1 )
 2535                                                         {
 2536                                                                 printf( "Error Reading Event Index\n" );
 2537  
 2538                                                                 return( TRC_FALSE );
 2539                                                         }
 2540  
 2541                                                         if ( index != dummy )
 2542                                                         {
 2543                                                                 printf( "Warning:  " );
 2544                                                                 printf( "Descriptor Index Mismatch  " );
 2545                                                                 printf( "%d != %d\n", index, dummy );
 2546  
 2547                                                                 index = dummy;
 2548                                                         }
 2549  
 2550                                                         if ( !trc_find_event_str( ID, ")" ) )
 2551                                                                 return( TRC_FALSE );
 2552                                                 }
 2553  
 2554                                                 else 
 2555                                                 {
 2556                                                         entry_exit = TRC_IGNORE_TEV;
 2557  
 2558                                                         if ( ee == 1 )
 2559                                                         {
 2560                                                                 printf( "Warning:  " );
 2561                                                                 printf( "Entry/Exit Mismatch  " );
 2562                                                                 printf( "%d != %d\n", ee, entry_exit );
 2563                                                         }
 2564  
 2565                                                         if ( index != dummy )
 2566                                                         {
 2567                                                                 printf( "Warning:  " );
 2568                                                                 printf( "Descriptor Index Mismatch  " );
 2569                                                                 printf( "%d != %d\n", index, dummy );
 2570  
 2571                                                                 index = dummy;
 2572                                                         }
 2573                                                 }
 2574  
 2575                                                 if ( !trc_find_event_str( ID, "\"" ) )
 2576                                                         return( TRC_FALSE );
 2577  
 2578                                                 if ( !(TD = trc_read_descriptor( 
 2579                                                         ID, eid, tmp, entry_exit, index )) )
 2580                                                 {
 2581                                                         return( TRC_FALSE );
 2582                                                 }
 2583  
 2584                                                 if ( ID->handle_descriptor )
 2585                                                         (ID->handle_descriptor)( ID, TD );
 2586                                         }
 2587  
 2588                                         /* PVM 3.3 Trace - Ignore Descriptor */ 
 2589  
 2590                                         else 
 2591                                         {
 2592                                                 eid = code;
 2593  
 2594                                                 if ( tmp[ i - 1 ] == '0' )   /* Buffer Overrun (ID: 2891.2957) */  /* Buffer Underrun (ID: 2892.2958) */
 2595                                                         entry_exit = TRC_ENTRY_TEV;
 2596  
 2597                                                 else if ( tmp[ i - 1 ] == '1' )   /* Buffer Underrun (ID: 2890.2956) */  /* Buffer Overrun (ID: 2889.2955) */
 2598                                                         entry_exit = TRC_EXIT_TEV;
 2599  
 2600                                                 else 
 2601                                                         entry_exit = TRC_IGNORE_TEV;
 2602  
 2603                                                 if ( !(TD = trc_read_descriptor( 
 2604                                                         ID, eid, tmp, entry_exit, -1 )) )
 2605                                                 {
 2606                                                         return( TRC_FALSE );
 2607                                                 }
 2608  
 2609                                                 if ( ID->handle_old_descriptor )
 2610                                                         (ID->handle_old_descriptor)( ID, TD );
 2611                                         }
 2612  
 2613                                         break;
 2614                                 }
 2615  
 2616                                 /* Record Data Packet */ 
 2617  
 2618                                 case '"': 
 2619                                 {
$input_305116 > 40952620                                         i = 0;
 2621  
 2622                                         while ( (c = getc( ID->trace_in )) != (char) EOF 
 2623                                                 && c != '"' && c != '(' )
 2624                                         {
 2625                                                 tmp[i++] = c;   /* Buffer Overrun (ID: 2893.2961) */
 2626                                         }
 2627  
 2628                                         TRC_CKEOF( c, "EOF Reading Event Record Name\n",
 2629                                                 return( TRC_FALSE ) );
 2630  
i > 40952631                                         tmp[i] = '\0';     /* Buffer Overrun */
 2632  
 2633                                         /* PVM 3.4 Trace */ 
 2634  
 2635                                         if ( c == '(' )
 2636                                         {
 2637                                                 /* Read in entry/exit or index value */ 
 2638  
 2639                                                 flag = fscanfID->trace_in, "%d", &dummy );
 2640  
 2641                                                 if ( flag != 1 )
   ...
 2695                                         {
 2696                                                 return( 
 2697                                                         trc_process_old_trace_event( ID, tmp ) );
 2698                                         }
 2699  
 2700                                         /* break; unreachable */ 
 2701                                 }
 2702  
 2703                                 /* Command Packet */ 
 2704  
 2705                                 case '%': 
 2706                                 {
 2707                                         tmp[0] = '%';
 2708  
 2709                                         if ( !trc_find_event_end_ret( ID, tmp + 1, 4095 ) )
 2710                                                 return( TRC_FALSE );
 2711  
 2712                                         if ( ID->handle_command )
 2713                                                 (ID->handle_command)( ID, tmp );
 2714  
 2715                                         break;
 2716                                 }
 2717  
 2718                                 /* Stream Attribute Packet */ 
 2719  
 2720                                 case '/': 
 2721                                 {
 2722                                         c = getc( ID->trace_in );
 2723  
 2724                                         TRC_CKEOF( c, "EOF Reading Trace Comment\n",
 2725                                                 return( TRC_FALSE ) );
 2726  
 2727                                         if ( c != '*' )
 2728                                         {
 2729                                                 printf( "\nError Reading Trace File\n" );
 2730                                                 printf( "\t- '*' expected (/* */)\n\n" );
 2731                                         }
 2732  
 2733                                         strcpy( tmp, "/*" );
 2734  
 2735                                         if ( !trc_find_event_end_ret( ID, tmp + 2, 4094 ) )
 2736                                                 return( TRC_FALSE );
 2737  
 2738                                         if ( ID->handle_comment )
 2739                                                 (ID->handle_comment)( ID, tmp );
 2740  
 2741                                         break;
 2742                                 }
 2743  
 2744                                 /* White Space */ 
 2745  
 2746                                 case ' ': 
 2747                                 case '\t': 
 2748                                 case '\n': 
 2749                                 {
 2750                                         break;
Preconditions
&$unknown_3152440 = 40
$input_305116 >= 1
$input_320316 = 34
$input_320324 != 34
$input_320324 != 40
$input_320324 <= 254
$input_320324 >= -1
$input_320332 = 40
Postconditions
ID' = $param_1
c' = &$unknown_3152440
eof' = $param_2
i' = $input_305116




Change Warning 2894.2962 : Buffer Overrun

Because they are very similar, this warning shares annotations with warning 2894.2960.
CodeSonar has selected warning 2894.2960 to represent this group of similar warnings. In order to edit this group, you must edit warning 2894.2960.