Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Null Pointer Dereference  at host.c:530

Categories: LANG.MEM.NPD CWE:476
Warning ID: 2560.2592
Procedure: ht_insert
Trace: View
Modified: Wed Sep 2 12:41:19 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/ddpro.c
   Enter startack
 2056 startack(wp, mp) 
 2057         struct waitc *wp;               /* wait context on hoster */ 
 2058         struct pmsg *mp;
 2059 {
 2060         struct hostd *hp;
 2061         struct pmsg *mp2;
 2062         struct waitc *wp2;              /* seed waitc for htupd peer group */ 
 2063         struct waitc *wp3;
 2064         int count;                              /* num of new hosts */ 
 2065         int happy;                              /* num of happy new hosts */ 
 2066         struct waitc_add *wxp;
   ...
 2070         int i, j;
 2071         int t;
 2072         int hh;
 2073         char *buf;
 2074         char buf2[256];
 2075  
 2076         /*
 2077         * unpack startup results, update hosts in wait context 
 2078         */ 
 2079  
 2080         wxp = (struct waitc_add *)wp->wa_spec;
 2081         count = wxp->w_num;
 2082         upkint(mp, &j);
 2083  
 2084         while (j-- > 0) {
 2085                 if (upkuint(mp, &t) || upkstralloc(mp, &buf)) {
 2086                         pvmlogerror("startack() bad message format\n");
 2087                         pkint(wp->wa_mesg, PvmDSysErr);
 2088                         sendmessage(wp->wa_mesg);
 2089                         wp->wa_mesg = 0;
 2090                         wait_delete(wp);
 2091                         busyadding = 0;
 2092                         return 0;
 2093                 }
 2094                 for (i = count; i-- > 0 && wxp->w_hosts[i]->hd_hostpart != t; ) ;
   ...
 2127                 hp->hd_mtu = atoi(av[3]);
 2128                 hp->hd_dsig = atoi(av[4]);
 2129  
 2130                 PVM_FREE(buf);
 2131         }
 2132  
 2133         /*
 2134         * update reply message to add-host requestor 
 2135         */ 
 2136  
 2137         mp2 = wp->wa_mesg;
 2138         pkint(mp2, count);
 2139         pkint(mp2, 0);  /* XXX narches = 0 for now */ 
 2140         for (i = 0; i < count; i++) {
 2141                 hp = wxp->w_hosts[i];
 2142                 if (hp->hd_err) {
 2143                         pkint(mp2, hp->hd_err);
 2144                         pkstr(mp2, "");
 2145                         pkstr(mp2, "");
 2146                         pkint(mp2, 0);
 2147                         pkint(mp2, 0);
 2148  
 2149                 } else {
 2150                         pkint(mp2, hp->hd_hostpart);
 2151                         pkstr(mp2, hp->hd_name);
 2152                         pkstr(mp2, hp->hd_arch);
 2153                         pkint(mp2, hp->hd_speed);
 2154                         pkint(mp2, hp->hd_dsig);
 2155                 }
 2156         }
 2157  
 2158         /*
 2159         * delete broken ones, done now if none succeeded,
 2160         * otherwise done when host table update is complete.
 2161         */ 
 2162  
 2163         for (j = i = 0; i < count; i++)
 2164                 if (!wxp->w_hosts[i]->hd_err) {
 2165                         hp = wxp->w_hosts[i];
 2166                         wxp->w_hosts[i] = 0;
 2167                         wxp->w_hosts[j++] = hp;
 2168  
 2169                 } else {
 2170                         hd_unref(wxp->w_hosts[i]);
 2171                         wxp->w_hosts[i] = 0;
 2172                 }
 2173         count = j;
 2174  
 2175         if (count < 1) {
 2176                 busyadding = 0;
 2177                 sendmessage(wp->wa_mesg);
 2178                 wp->wa_mesg = 0;
 2179                 free_waitc_add(wxp);
 2180                 wait_delete(wp);
 2181                 return 0;
 2182         }
 2183  
 2184         wp2 = wait_new(WT_HTUPD);
 2185         wp2->wa_dep = wp->wa_dep;
 2186         wp2->wa_mesg = wp->wa_mesg;
 2187         wp->wa_mesg = 0;
 2188  
 2189         /*
 2190         * make next host table 
 2191         */ 
 2192  
true2193         newhosts = ht_new(1);   /* Leak (ID: 2557.2588) */
 2194         newhosts->ht_serial = hosts->ht_serial + 1;
 2195         newhosts->ht_master = hosts->ht_master;
 2196         newhosts->ht_cons = hosts->ht_cons;
 2197         newhosts->ht_local = hosts->ht_local;
 2198  
 2199         for (i = 0; i < count; i++)
newhosts->ht_last < 5112200                 ht_insert(newhosts, wxp->w_hosts[i]);
     /u1/paul/SATE/2010/c/pvm/pvm3/src/host.c
     Enter startack / ht_insert
((char*)$param_1)[4] < 511507   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) {
htp->ht_last < 511525                   int n = htp->ht_last;
 526    
 527                   htp->ht_last = (hh * 3) / 2;
n < 511528                   htp->ht_hosts = TREALLOC(htp->ht_hosts, htp->ht_last + 1, struct hostd*);
 529                   while (++n <= htp->ht_last)
htp->ht_hosts <= 4095530                           htp->ht_hosts[n] = 0;     /* Null Pointer Dereference */  /* 6 more... */
     Exit startack / ht_insert
Preconditions
&$unknown_602999 >= 1
&$unknown_603002 >= 2
&$unknown_603003 >= 2
((char*)*$param_1)[72] >= 2
widrange >= lastwid + 1
Postconditions
count' = &$unknown_602999
$heap_35999' = &$unknown_603000
bytes_after(&$heap_35999)' = 80
$heap_35999' is allocated by malloc
$heap_35999' is allocated
bytes_before(&$heap_35999)' = 0
((char*)&$heap_35999)[16]' <= ((char*)&$unknown_603000)[16] - 1
((char*)&$heap_35999)[20]' = 6
((char*)&$heap_35999)[24]' = 0
((char*)&$heap_35999)[28]' = 0
((char*)&$heap_35999)[32]' = ((char*)$param_1)[32]
((char*)&$heap_35999)[56]' = ((char*)$param_1)[56]
((char*)&$heap_35999)[64]' = 0
((char*)&$heap_35999)[72]' = 0
((char*)&$heap_35999)[8]' = ((char*)&$unknown_603000)[8]
$heap_36000' = hosts->ht_serial + 1
bytes_after(&$heap_36000)' = 40
$heap_36000' is allocated by malloc
$heap_36000' is allocated
bytes_before(&$heap_36000)' = 0
strlen(&$heap_36000)' = 0
((char*)&$heap_36000)[16]' = hosts->ht_cons
((char*)&$heap_36000)[20]' = hosts->ht_local
((char*)&$heap_36000)[32]' = 0
((char*)&$heap_36000)[4]' = &$unknown_603003
((char*)&$heap_36000)[12]' = hosts->ht_master
$heap_36001' = 0
bytes_after(&$heap_36001)' = 16
$heap_36001' is allocated by malloc
$heap_36001' is allocated
bytes_before(&$heap_36001)' = 0
strlen(&$heap_36001)' = 0
hh' = &$unknown_603002
hp' = &$unknown_602998
hp' = ((char*)((char*)*$param_1)[72])[8]
htp' = &$heap_36000
i' = 0
j' = &$unknown_602999
mask' = 0
mp' = $param_2
mp2' = ((char*)$param_1)[56]
n' = 2
newhosts' = &$heap_36000
wp' = $param_1
wp2' = &$heap_35999
wxp' = ((char*)$param_1)[72]




Change Warning 2560.2592 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: