Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Null Pointer Dereference  at msgbox.c:385

Categories: LANG.MEM.NPD CWE:476
Warning ID: 169.28791
Procedure: mb_insert
Trace: view
Modified: Thu Nov 26 11:27:56 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/src/msgbox.c
   Enter mb_insert
 321 mb_insert(tid, name, req, flags, mp) 
 322         int tid;                                /* owner task */ 
 323         char *name;                             /* class name */ 
 324         int req;                                /* index requested or -1 for lowest avail */ 
 325         int flags;
 326         struct pmsg *mp;                /* message to store */ 
 327 {
 328         struct pvmmclass *np;
 329         struct pvmmentry *ep;
 330         struct pvmmentry *ep2 = 0;
 331  
 332         int dind;       /* direct index */ 
 333         int cind;       /* current index */ 
 334  
 335         /* must change to always pass in -1 for 3.4 calls */ 
 336         /* then can distinguish between 3.4 reinsert which succeeds 
 337                 if !overwritable/minst & 3.3 reinsert which should fail */ 
 338         /* to fix the "if (ep->me_ind == req)" conditional 
 339                 use a "current index":  cind = ( req == -1 ) ? 0 : req; */ 
 340         /* also, minst supercedes overwritable, else no way to build 
 341                 a minst list from within a single task... */ 
 342  
 343         if (!(np = mc_find(name)))
 344                 if (!(np = mc_new(name)))
 345                         return PvmNoMem;
 346  
 347         dind = PvmMboxDirectIndexOf( flags );
 348  
 349         cind = ( req == -1 ) ? 
 350                 ( ( dind ) ? dind : 0 ) 
 351                 : req;
 352  
 353         for (ep = np->mc_ent->me_link; ep != np->mc_ent; ep = ep->me_link)   /* Null Pointer Dereference (ID: 170.28792) */
 354                 if (ep->me_ind >= cind)
 355                         break;
 356  
 357         /* default insert is "locked"... */ 
 358  
 359         if (ep->me_ind == cind) {
 360                 if (flags & PvmMboxMultiInstance) {
 361                         if ( req != -1 ) /* hack for 3.3 compat */ 
 362                                 return PvmDenied;
 363                         for (; ep != np->mc_ent; ep = ep->me_link) {
 364                                 if (ep->me_ind != cind)
 365                                         break;
 366                                 cind++;
 367                         }
 368                 } else {
 369                         if ( !(ep->me_flags & PvmMboxOverWritable) 
 370                                         && tid != ep->me_tid) {
 371                                 return PvmDenied;
 372                         }
 373                         ep2 = ep;
 374                 }
 375         }
 376  
 377         if (ep2) {
 378                 ep = ep2->me_link;
 379                 LISTDELETE(ep2, me_link, me_rlink);
 380                 pmsg_unref(ep2->me_msg);
 381                 PVM_FREE(ep2);
 382         }
 383  
true384         ep2 = me_new(cind);
ep2 <= 4095385         ep2->me_tid = tid;     /* Null Pointer Dereference */
Preconditions
req = -1
&$heap_69539 != $unknown_579414
&$heap_69539 != $heap_69539
((char*)&((char*)*$unknown_579414)[24])[20] <= 1
((char*)$unknown_579414)[8] = 0
((char*)$heap_69539)[8] <= -1
((char*)&$unknown_579414)[8] <= -1
Postconditions
((char*)&((char*)((char*)*$unknown_579414)[24])[12])[24]' = ((char*)&((char*)((char*)*$unknown_579414)[24])[12])[24] - 1
((char*)&((char*)*$unknown_579414)[24])[20]' = ((char*)&((char*)*$unknown_579414)[24])[20] - 1
((char*)$unknown_579414)[4]' = 0
pvmmboxclasses->mc_rlink' = &$heap_69537
((char*)*$unknown_579414)[24]' = &freepmsgs.m_link
((char*)*$unknown_579414)[4]' = *$unknown_579414
pvmmboxclasses->mc_rlink->mc_link' = &$heap_69537
*$unknown_579414' = 0
*$unknown_579414' is freed
cind' = 0
dind' = 0
ep' = *$unknown_579414
ep2' = 0
errno' != 0
freepmsgs.m_rlink' = ((char*)$unknown_579414)[24]
$heap_69537' = pvmmboxclasses
bytes_after(&$heap_69537)' = 16
$heap_69537' is allocated by malloc
$heap_69537' is allocated
bytes_before(&$heap_69537)' = 0
((char*)&$heap_69537)[4]' = pvmmboxclasses->mc_rlink
((char*)&$heap_69537)[8]' = &$heap_69538
((char*)&$heap_69537)[12]' = &$heap_69539
$heap_69538' = *name
bytes_after(&$heap_69538)' = strlen(name) + 1
$heap_69538' is allocated by malloc
$heap_69538' is allocated
bytes_before(&$heap_69538)' = 0
strlen(&$heap_69538)' = strlen(name)
tocttou($heap_69538)' = tocttou(*name)
bytes_after(&$heap_69539)' = 28
$heap_69539' is allocated by malloc
$heap_69539' is allocated
bytes_before(&$heap_69539)' = 0
((char*)&$heap_69539)[16]' = 0
((char*)&$heap_69539)[20]' = 0
((char*)&$heap_69539)[24]' = 0
((char*)&$heap_69539)[8]' = -1
((char*)&$heap_69539)[12]' = 0
np' = &$heap_69537
numpmsgs' = numpmsgs + 1




Change Warning 169.28791 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: