Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Integer Overflow of Allocation Size  at trcmess.c:130

Categories: ALLOC.IOAS BSI:MALLOC-OVERFLOW CWE:680
Warning ID: 22169.29207
Procedure: trc_recv_messages
Trace: view
Modified: Thu Nov 26 11:36:07 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
   /kat0/fletcher/SATE/2010/pvm3/tracer/trcmess.c
   Enter trc_recv_messages
 42 trc_recv_messages( ID, max_count, status ) 
 43 TRC_ID ID;
 44 int max_count;
 45 int *status;
 46 {
 47         static int *tids = (int *) NULL;
 48         static int ntids = 0;
 49  
 50         TRC_HOST H;
 51  
 52         TRC_ID DEAD_ID_last;
   ...
 61         int mid;
 62         int num;
 63         int tid;
 64         int src;
 65         int tmp;
 66         int cc;
 67         int i;
 68  
 69         /* Verify Message Codes Set */ 
 70  
 71         if ( TRC_HOST_ADD_NOTIFY_CODE == -1 
 72                 || TRC_HOST_DEL_NOTIFY_CODE == -1 
 73 #ifndef USE_PVM_33 
 74                 || ID->event_ctx == -1 || ID->output_ctx == -1 
 75 #endif 
 76                 || ID->event_tag == -1 || ID->output_tag == -1 )
 77         {
 78                 printf( "Error: Message Codes Not Set - %d %d %d %d %d %d\n",
 79                         TRC_HOST_ADD_NOTIFY_CODE, TRC_HOST_DEL_NOTIFY_CODE,
 80                         ID->event_ctx, ID->output_ctx,
 81                         ID->event_tag, ID->output_tag );
 82  
 83                 return( -1 );
 84         }
 85  
 86         /* Clear Out Flags */ 
 87  
 88         if ( status != NULL )
 89                 *status = TRC_MSG_STATUS_NONE;
 90  
 91         /* Init Event Counter */ 
 92  
 93         ecnt = 0;
 94  
 95         /* Check for Host Sync Updates */ 
 96  
 97         ecnt += trc_check_host_sync( ID );   /* Useless Assignment (ID: 448.29205) */
 98  
 99         /* Receive Stuff */ 
 100  
 101         cnt = 0;
 102  
 103         while ( cnt < max_count 
 104                 && (mid = trc_get_msg( ID, &len, &msgtag, &src, &others )) > 0 )
 105         {
 106                 /* Set Activity Flag */ 
 107  
 108                 if ( status != NULL )
 109                         *status |= TRC_MSG_STATUS_ACTIVE;
 110  
 111                 /* Host Added */ 
 112  
 113                 if ( msgtag == TRC_HOST_ADD_NOTIFY_CODE && src == 0x80000000 )
 114                 {
 115                         cc = pvm_upkint( &num, 1, 1 );
 116  
 117                         if ( cc < 0 )
 118                                 pvm_perror( "Error Unpacking Host Add Notify" );
 119  
 120                         else 
 121                         {
 122                                 if ( num > ntids )
 123                                 {
 124                                         ntids = num * 2;
 125  
 126                                         if ( tids )
 127                                                 free( tids );
 128  
 129                                         tids = (int *) malloc( (unsigned) ntids 
true130                                                 * sizeof(int) );     /* Integer Overflow of Allocation Size */
 131                                         trc_memcheck( tids, "Host Add Notify Tids Array" );
 132                                 }
 133  
 134                                 cc = pvm_upkint( tids, num, 1 );
 135  
 136                                 if ( cc < 0 )
 137                                         pvm_perror( "Error Unpacking Host Add TIDs" );
 138  
 139                                 else 
 140                                 {
 141                                         pvm_notify( PvmHostDelete,
 142                                                 TRC_HOST_DEL_NOTIFY_CODE, num, tids );
 143  
 144                                         ecnt += trc_handle_host_add_notify( ID, tids, num );
 145                                 }
 146                         }
 147                 }
 148  
 149                 /* Host Deleted */ 
 150  
 151                 else if ( msgtag == TRC_HOST_DEL_NOTIFY_CODE 
 152                         && src == 0x80000000 )
 153                 {
 154                         cc = pvm_upkint( &tid, 1, 1 );
 155  
 156                         if ( cc < 0 )
 157                                 pvm_perror( "Error Unpacking Host Delete Notify" );
 158  
 159                         else 
 160                                 ecnt += trc_handle_host_del_notify( ID, tid );   /* Uninitialized Variable (ID: 449.29208) */
 161                 }
 162  
 163                 /* PVM Trace Event */ 
 164  
 165                 else if ( msgtag == ID->event_tag )
 166                 {
 167                         ecnt += trc_handle_trace_message( ID, src );
 168  
 169                         if ( status != NULL )
 170                         {
 171                                 if ( ecnt )
 172                                         *status |= TRC_MSG_STATUS_OVERWRITE;
 173  
 174                                 else 
 175                                         *status |= TRC_MSG_STATUS_CLEANUP;
 176                         }
 177                 }
 178  
 179                 /* PVM Output Event */ 
 180  
 181                 else if ( msgtag == ID->output_tag )
 182                 {
 183                         ecnt += trc_handle_output_message( ID );
 184  
 185                         if ( status != NULL )
 186                         {
 187                                 if ( ecnt )
 188                                         *status |= TRC_MSG_STATUS_OVERWRITE;
 189  
 190                                 else 
 191                                         *status |= TRC_MSG_STATUS_CLEANUP;
 192                         }
 193                 }
 194  
 195                 /* Unknown Message */ 
 196  
 197                 else 
 198                 {
 199                         fprintf( stderr,
 200                                 "Tracer:  msg from 0x%x code %d len %d ?\n",
 201                                 src, msgtag, len );
 202                 }
 203  
 204                 if ( pvm_freebuf( mid ) < 0 )
 205                         pvm_perror( "Error Freeing Message Buffer" );
 206  
 207                 cnt++;
Preconditions
max_count >= 2
&$unknown_12004734 >= 1
&$unknown_12004735 != 0
&$unknown_12004736 != 0
ID->output_ctx != -1
ID->output_tag != -1
ID->event_ctx != -1
ID->event_tag != -1
TRC_HOST_ADD_NOTIFY_CODE != -1
TRC_HOST_DEL_NOTIFY_CODE != -1
$input_12 = 0
Postconditions
$unknown_12004736' is freed
cc' >= 0
mid' = &$unknown_12004734
msgtag' = TRC_HOST_ADD_NOTIFY_CODE
pvmrbuf' = &$unknown_12004735
tids' = &$unknown_12004736




Change Warning 22169.29207 : Integer Overflow of Allocation Size

Priority:
State:
Finding:
Owner:
Note: