Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Null Pointer Dereference  at host.c:573

Categories: LANG.MEM.NPD CWE:476
Warning ID: 63.28649
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++ ) {
dsigs <= 4095573                                 if ( dsigs[i] == d )     /* Null Pointer Dereference */
 574                                         found++;
 575                         }
 576                         if ( !found ) {
 577                                 dsigs[ ndsigs++ ] = d;   /* Null Pointer Dereference (ID: 62.28648) */
 578                                 htp->ht_narch++;
Preconditions
&$unknown_66934 >= htp->ht_last + 1
&$unknown_66934 >= 3
&$unknown_66935 >= 1
htp->ht_hosts = 0
((char*)&((char*)$heap_2505)[8])[12] != 0
Postconditions
((char*)$unknown_66933)[8]' is freed
((char*)$unknown_66933)[12]' is freed
strlen(&$unknown_66933)' = strlen(hp)
((char*)&$unknown_66933)[44]' = hp->hd_dsig
((char*)&$unknown_66933)[52]' = hp->hd_mtu
((char*)&$unknown_66933)[56]' = hp->hd_sad.sin_family
((char*)&$unknown_66933)[58]' = hp->hd_sad.sin_port
((char*)&$unknown_66933)[60]' = hp->hd_sad.sin_addr.s_addr
((char*)&$unknown_66933)[64]' = hp->hd_sad.sin_zero[0]
((char*)&$unknown_66933)[8]' = &$heap_2506
((char*)&$unknown_66933)[108]' = hp->hd_speed
((char*)&$unknown_66933)[12]' = &$heap_2507
d' = ((char*)&((char*)$heap_2505)[8])[44]
dsigs' = 0
errno' != 0
found' = 0
bytes_after(&$heap_2505)' = 4 * &$unknown_66934 + 4
$heap_2505' is allocated by malloc
$heap_2505' is allocated
bytes_before(&$heap_2505)' = 0
$heap_2506' = *hp->hd_name
bytes_after(&$heap_2506)' = strlen(hp->hd_name) + 1
$heap_2506' is allocated by malloc
$heap_2506' is allocated
bytes_before(&$heap_2506)' = 0
strlen(&$heap_2506)' = strlen(hp->hd_name)
tocttou($heap_2506)' = tocttou(*hp->hd_name)
$heap_2507' = *hp->hd_arch
bytes_after(&$heap_2507)' = strlen(hp->hd_arch) + 1
$heap_2507' is allocated by malloc
$heap_2507' is allocated
bytes_before(&$heap_2507)' = 0
strlen(&$heap_2507)' = strlen(hp->hd_arch)
tocttou($heap_2507)' = tocttou(*hp->hd_arch)
hh' = 2
hp' = ((char*)&$heap_2505)[8]
hp2' = &$unknown_66933
i' = 0
mask' = 0
n' = &$unknown_66934 + 1
ndsigs' = &$unknown_66935




Change Warning 63.28649 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: