Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Null Pointer Dereference  at msgbox.c:385

Categories: LANG.MEM.NPD CWE:476
Warning ID: 2585.2617
Procedure: mb_insert
Trace: View
Modified: Wed Sep 2 12:41:42 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/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: 2586.2618) */
 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
$param_3 = -1
&$heap_38304 != $heap_38304
((char*)&((char*)*$unknown_651917)[32])[40] <= 1
((char*)$unknown_651917)[16] = 0
((char*)$heap_38304)[16] <= -1
$unknown_651917 != &$heap_38304
((char*)&$unknown_651917)[16] <= -1
Postconditions
((char*)&((char*)((char*)*$unknown_651917)[32])[24])[40]' = ((char*)&((char*)((char*)*$unknown_651917)[32])[24])[40] - 1
((char*)&((char*)*$unknown_651917)[32])[40]' = ((char*)&((char*)*$unknown_651917)[32])[40] - 1
((char*)$unknown_651917)[8]' = 0
pvmmboxclasses->mc_rlink' = &$heap_38306
((char*)*$unknown_651917)[32]' = &freepmsgs.m_link
((char*)*$unknown_651917)[8]' = *$unknown_651917
pvmmboxclasses->mc_rlink->mc_link' = &$heap_38306
*$unknown_651917' = 0
*$unknown_651917' is freed
cind' = 0
dind' = 0
ep' = *$unknown_651917
ep2' = 0
flags' = $param_4
freepmsgs.m_rlink' = ((char*)$unknown_651917)[32]
bytes_after(&$heap_38304)' = 40
$heap_38304' is allocated by malloc
$heap_38304' is allocated
bytes_before(&$heap_38304)' = 0
((char*)&$heap_38304)[16]' = -1
((char*)&$heap_38304)[20]' = 0
((char*)&$heap_38304)[24]' = 0
((char*)&$heap_38304)[28]' = 0
((char*)&$heap_38304)[32]' = 0
$heap_38305' = *$param_2
bytes_after(&$heap_38305)' = strlen($param_2) + 1
$heap_38305' is allocated by malloc
$heap_38305' is allocated
bytes_before(&$heap_38305)' = 0
strlen(&$heap_38305)' = strlen($param_2)
$heap_38306' = pvmmboxclasses
bytes_after(&$heap_38306)' = 32
$heap_38306' is allocated by malloc
$heap_38306' is allocated
bytes_before(&$heap_38306)' = 0
((char*)&$heap_38306)[16]' = &$heap_38305
((char*)&$heap_38306)[24]' = &$heap_38304
((char*)&$heap_38306)[8]' = pvmmboxclasses->mc_rlink
mp' = $param_5
name' = $param_2
np' = &$heap_38306
numpmsgs' = numpmsgs + 1
req' = $param_3
tid' = $param_1




Change Warning 2585.2617 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: