Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Free Null Pointer  at host.c:583

Categories: ALLOC.FNP CWE:590
Warning ID: 64.28650
Procedure: ht_insert
Trace: view
Modified: Thu Nov 26 11:27:15 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/host.c
   Enter ht_insert
 507 ht_insert(htp, hp) 
 508         struct htab *htp;
 509         struct hostd *hp;
 510 {
 511         int hh;
 512         int i;
 513         unsigned long mask = 0, tmpmask;
 514  
 515         int *dsigs;
 516         int ndsigs;
 517         int found;
 518         int d;
 519  
 520         hh = (hp->hd_hostpart & tidhmask) >> (ffs(tidhmask) - 1);
 521  
 522         /* extend ht_hosts[] if no room */ 
 523  
 524         if (hh > htp->ht_last) {
 525                 int n = htp->ht_last;
 526  
 527                 htp->ht_last = (hh * 3) / 2;
 528                 htp->ht_hosts = TREALLOC(htp->ht_hosts, htp->ht_last + 1, struct hostd*);   /* Integer Overflow of Allocation Size (ID: 70.28656) */
 529                 while (++n <= htp->ht_last)
 530                         htp->ht_hosts[n] = 0;   /* Null Pointer Dereference (ID: 69.28655) */
 531         }
 532  
 533         /* if already have an entry, take this as an update XXX kind of a hack */ 
 534  
 535         if (htp->ht_hosts[hh]) {        /* already have an entry */   /* Null Pointer Dereference (ID: 68.28654) */
 536  
 537                 struct hostd *hp2 = htp->ht_hosts[hh];
 538  
 539                 if (hp->hd_name) {
 540                         if (hp2->hd_name)
 541                                 PVM_FREE(hp2->hd_name);
 542                         hp2->hd_name = STRALLOC(hp->hd_name);   /* Null Pointer Dereference (ID: 67.28653) */
 543                 }
 544                 if (hp->hd_arch) {
 545                         if (hp2->hd_arch)
 546                                 PVM_FREE(hp2->hd_arch);
 547                         hp2->hd_arch = STRALLOC(hp->hd_arch);   /* Null Pointer Dereference (ID: 66.28652) */
 548                 }
 549                 hp2->hd_dsig = hp->hd_dsig;
 550                 hp2->hd_mtu = hp->hd_mtu;
 551                 hp2->hd_sad = hp->hd_sad;
 552                 hp2->hd_speed = hp->hd_speed;
 553  
 554         } else {                                        /* add new entry */ 
 555  
 556                 htp->ht_hosts[hh] = hp;
 557                 if (hh)
 558                         htp->ht_cnt++;
 559                 hp->hd_ref++;
 560         }
 561  
 562         /* update number of arches */ 
 563  
true564         dsigs = TALLOC( htp->ht_cnt, int, "dsigs");   /* Integer Overflow of Allocation Size (ID: 65.28651) */
 565         ndsigs = 0;
 566  
 567         htp->ht_narch = 0;
 568         for (hh = htp->ht_last; hh > 0; hh--) {
 569                 hp = htp->ht_hosts[hh];
 570                 if (hp && hp->hd_arch) {
 571                         d = htp->ht_hosts[hh]->hd_dsig;
 572                         for ( i=0, found=0 ; i < ndsigs && !found ; i++ ) {
 573                                 if ( dsigs[i] == d )   /* Null Pointer Dereference (ID: 63.28649) */
 574                                         found++;
 575                         }
 576                         if ( !found ) {
 577                                 dsigs[ ndsigs++ ] = d;   /* Null Pointer Dereference (ID: 62.28648) */
 578                                 htp->ht_narch++;
 579                         }
 580                 }
 581         }
 582  
dsigs <= 4095583         PVM_FREE( dsigs );     /* Free Null Pointer */
Preconditions
&$unknown_67017 >= htp->ht_last + 1
&$unknown_67017 >= 2
htp->ht_hosts = 0
((char*)&((char*)$heap_2709)[4])[12] = 0
Postconditions
((char*)$unknown_67016)[8]' is freed
((char*)$unknown_67016)[12]' is freed
strlen(&$unknown_67016)' = strlen(hp)
((char*)&$unknown_67016)[44]' = hp->hd_dsig
((char*)&$unknown_67016)[52]' = hp->hd_mtu
((char*)&$unknown_67016)[56]' = hp->hd_sad.sin_family
((char*)&$unknown_67016)[58]' = hp->hd_sad.sin_port
((char*)&$unknown_67016)[60]' = hp->hd_sad.sin_addr.s_addr
((char*)&$unknown_67016)[64]' = hp->hd_sad.sin_zero[0]
((char*)&$unknown_67016)[8]' = &$heap_2710
((char*)&$unknown_67016)[108]' = hp->hd_speed
((char*)&$unknown_67016)[12]' = &$heap_2711
dsigs' = 0
errno' != 0
bytes_after(&$heap_2709)' = 4 * &$unknown_67017 + 4
$heap_2709' is allocated by malloc
$heap_2709' is allocated
bytes_before(&$heap_2709)' = 0
$heap_2710' = *hp->hd_name
bytes_after(&$heap_2710)' = strlen(hp->hd_name) + 1
$heap_2710' is allocated by malloc
$heap_2710' is allocated
bytes_before(&$heap_2710)' = 0
strlen(&$heap_2710)' = strlen(hp->hd_name)
tocttou($heap_2710)' = tocttou(*hp->hd_name)
$heap_2711' = *hp->hd_arch
bytes_after(&$heap_2711)' = strlen(hp->hd_arch) + 1
$heap_2711' is allocated by malloc
$heap_2711' is allocated
bytes_before(&$heap_2711)' = 0
strlen(&$heap_2711)' = strlen(hp->hd_arch)
tocttou($heap_2711)' = tocttou(*hp->hd_arch)
hh' = 0
hp' = ((char*)&$heap_2709)[4]
hp2' = &$unknown_67016
mask' = 0
n' = &$unknown_67017 + 1




Change Warning 64.28650 : Free Null Pointer

Priority:
State:
Finding:
Owner:
Note: