Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Buffer Overrun  at pvmd.c:5238

Categories: LANG.MEM.BO CWE:120 CWE:121 CWE:122 CWE:126
Warning ID: 22084.28921
Procedure: varsub
Trace: view
Modified: Thu Nov 26 11:28:38 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/pvmd.c
   Enter master_config
 5317 master_config(hn, argc, argv) 
 5318         char *hn;                       /* hostname or null */ 
 5319         int argc;
 5320         char **argv;
 5321 {
 5322         struct hostent *he;
 5323         struct hostd *hp;
 5324         struct hostd *hp2;
 5325         int i;
 5326         char *s;
 5327  
 5328         if (argc > 2) {
 5329                 pvmlogerror("usage: pvmd3 [-ddebugmask] [-nhostname] [hostfile]\n");
 5330                 pvmbailout(0);
 5331         }
 5332         if (argc == 2) {
 5333                 filehosts = readhostfile(argv[1]);
 5334         }
 5335         else if (s = getenv("PVMHOSTFILE")) {
 5336                 filehosts = readhostfile(s);
 5337         }
 5338         if (pvmdebmask & PDMSTARTUP) {
 5339                 if (filehosts) {
 5340                         pvmlogerror("master_config() host file:\n");
 5341                         ht_dump(filehosts);
 5342  
 5343                 } else 
 5344                         pvmlogerror("master_config() null host file\n");
 5345         }
 5346  
 5347         hosts = ht_new(1);
 5348         hosts->ht_serial = 1;
 5349         hosts->ht_master = 1;
 5350         hosts->ht_cons = 1;
 5351         hosts->ht_local = 1;
 5352  
 5353         hp = hd_new(1);
 5354         hp->hd_name = STRALLOC(hn);   /* Null Pointer Dereference (ID: 265.28929) */
 5355         hp->hd_arch = STRALLOC(myarchname);   /* Null Pointer Dereference (ID: 263.28928) */
 5356         hp->hd_mtu = pvmudpmtu;
 5357         hp->hd_dsig = pvmmydsig;
 5358         ht_insert(hosts, hp);
 5359         hd_unref(hp);
 5360  
 5361         hp = hd_new(0);
 5362         hp->hd_name = STRALLOC("pvmd'");   /* Null Pointer Dereference (ID: 264.28927) */
 5363         hp->hd_arch = STRALLOC(myarchname);   /* Null Pointer Dereference (ID: 263.28925) */
 5364         hp->hd_mtu = pvmudpmtu;
 5365         hp->hd_dsig = pvmmydsig;
 5366         ht_insert(hosts, hp);
 5367         hd_unref(hp);
 5368  
 5369         /*
 5370         * get attributes from host file if available 
 5371         */ 
 5372  
 5373         hp = hosts->ht_hosts[1];
 5374         if (filehosts &&
 5375                         ((hp2 = nametohost(filehosts, hp->hd_name)) 
 5376                         || (hp2 = filehosts->ht_hosts[0]))) {
 5377                 applydefaults(hp, hp2);
 5378         }
 5379  
 5380         if (!hp->hd_epath) {
 5381                 if ((s = getenv("PVM_PATH")))
 5382                         hp->hd_epath = STRALLOC(s);   /* Null Pointer Dereference (ID: 22087.28924) */
 5383                 else 
 5384                         hp->hd_epath = STRALLOC(DEFBINDIR);   /* Null Pointer Dereference (ID: 22086.28923) */
 5385         }
 5386         epaths = colonsep(varsub(hp->hd_epath));
 5387         if (!hp->hd_bpath)
 5388                 hp->hd_bpath = STRALLOC(DEFDEBUGGER);   /* Null Pointer Dereference (ID: 22083.28920) */
 5389         debugger = varsub(hp->hd_bpath);
 5390         if (!hp->hd_wdir) {
 5391                 if ((s = getenv("PVM_WD")))
 5392                         hp->hd_wdir = STRALLOC(s);   /* Null Pointer Dereference (ID: 22082.28919) */
 5393                 else 
true5394                         hp->hd_wdir = STRALLOC(pvmgethome());   /* Null Pointer Dereference (ID: 22081.28918) */
 5395         }
bytes_after(hp->hd_wdir) < 35396         s = varsub(hp->hd_wdir);
     Enter master_config / varsub
 5205   char * 
 5206   varsub(s) 
 5207           char *s;
 5208   {
 5209           int rm = 8;             /* length of result string space */ 
 5210           char *r;                /* result string */ 
 5211           int rl = 0;
 5212           char *p;
 5213           char *vn, *vv;
 5214           char c;
 5215           int l;
 5216    
 5217           r = TALLOC(rm, char, "var");
 5218           while (*s) {   /* Null Pointer Dereference (ID: 143.28764) */
bytes_after(s) < 35219                   for (p = s; *p && *p != '$'; p++) ;
 5220                   if (l = p - s) {
 5221                           if (rl + l >= rm) {
 5222                                   rm = rl + l + 1;
 5223                                   r = TREALLOC(r, rm, char);
 5224                           }
 5225                           strncpy(r + rl, s, l);   /* Null Pointer Dereference (ID: 138.28759) */
 5226                           rl += l;
 5227                   }
bytes_after(p) < 35228                   s = p++;
 5229                   if (*s == '$') {
 5230                           if (*p == '{')
bytes_after(p) < 25231                                   p++;
bytes_after(p) < 15232                           vn = p;
 5233                           while (isalnum(*p) || *p == '_')   /* Buffer Overrun (ID: 22085.28922) */  /* 2 more... */
 5234                                   p++;
 5235                           c = *p;
 5236                           *p = 0;
 5237    
bytes_after(vn) < 15238                           vv = getenv(vn);     /* Buffer Overrun */  /* Buffer Overrun (ID: 22067.28896) */
     Exit master_config / varsub
Preconditions
$param_2 = 2
&$unknown_764841 >= &$heap_214203 + 2
((char*)((char*)((char*)$heap_214186)[28])[4])[24] != 36
((char*)((char*)((char*)$heap_214186)[28])[4])[28] != 0
strlen(((char*)&((char*)((char*)$heap_214186)[28])[4])[28]) != 0
strlen(&$unknown_764839) != 1
strlen(&$unknown_764839) > 0
((char*)&$unknown_764841)[1] != 95
((char*)&$heap_214197)[20] = 0
((char*)&$heap_214197)[96] >= 0
$heap_214201 != 58
$heap_214203 = 36
((char*)&$heap_214203)[1] = 123
Postconditions
((char*)&((char*)((char*)$heap_214186)[28])[4])[32]' = &$heap_214203
$unknown_764838' is allocated by malloc
strlen(&$unknown_764841)' = 1
((char*)&$unknown_764841)[1]' = 0
atnewline' = 1
c' = ((char*)&$unknown_764841)[1]
debugger' = &$unknown_764838
epaths' = &$heap_214202
errno' != 0
filehosts' = 0
hd' = &#string17[0]
$heap_214186' = 1
bytes_after(&$heap_214186)' = 32
$heap_214186' is allocated by malloc
$heap_214186' is allocated
bytes_before(&$heap_214186)' = 0
((char*)&$heap_214186)[16]' = 1
((char*)&$heap_214186)[20]' = 1
((char*)&$heap_214186)[8]' = ((char*)&$heap_214186)[8] + 1
((char*)&$heap_214186)[12]' = 1
bytes_after(&$heap_214187)' = 120
$heap_214187' is allocated by malloc
$heap_214187' is allocated
bytes_before(&$heap_214187)' = 0
((char*)&$heap_214187)[16]' = 0
((char*)&$heap_214187)[20]' = 0
((char*)&$heap_214187)[8]' = 0
((char*)&$heap_214187)[116]' = 0
((char*)&$heap_214187)[12]' = 0
bytes_after(&$heap_214188)' = 120
$heap_214188' is allocated by malloc
$heap_214188' is allocated
bytes_before(&$heap_214188)' = 0
((char*)&$heap_214188)[16]' = 0
((char*)&$heap_214188)[20]' = 0
((char*)&$heap_214188)[8]' = 0
((char*)&$heap_214188)[116]' = 0
((char*)&$heap_214188)[12]' = 0
bytes_after(&$heap_214189)' = 20
$heap_214189' is allocated by malloc
$heap_214189' is allocated
bytes_before(&$heap_214189)' = 0
((char*)&$heap_214189)[16]' = 0
((char*)&$heap_214189)[8]' = 0
((char*)&$heap_214189)[12]' = 0
$heap_214190' = 1
bytes_after(&$heap_214190)' = 124
$heap_214190' is allocated by malloc
bytes_before(&$heap_214190)' = 0
((char*)&$heap_214190)[44]' = pvmmydsig
((char*)&$heap_214190)[52]' = pvmudpmtu
((char*)&$heap_214190)[56]' = 2
((char*)&$heap_214190)[72]' = 1
((char*)&$heap_214190)[76]' = 1
((char*)&$heap_214190)[80]' = &$heap_214191
((char*)&$heap_214190)[8]' = &$heap_214192
((char*)&$heap_214190)[84]' = &$heap_214188
((char*)&$heap_214190)[92]' = &$heap_214187
((char*)&$heap_214190)[100]' = 1
((char*)&$heap_214190)[108]' = 1000
((char*)&$heap_214190)[112]' = &$heap_214189
((char*)&$heap_214190)[12]' = &$heap_214193
$heap_214191' = &$heap_214191
bytes_after(&$heap_214191)' = 120
$heap_214191' is allocated by malloc
$heap_214191' is allocated
bytes_before(&$heap_214191)' = 0
((char*)&$heap_214191)[16]' = 0
((char*)&$heap_214191)[20]' = 0
((char*)&$heap_214191)[4]' = &$heap_214191
((char*)&$heap_214191)[8]' = 0
((char*)&$heap_214191)[116]' = 0
((char*)&$heap_214191)[12]' = 0
$heap_214192' = *hn
bytes_after(&$heap_214192)' = strlen(hn) + 1
$heap_214192' is allocated by malloc
$heap_214192' is allocated
bytes_before(&$heap_214192)' = 0
strlen(&$heap_214192)' = strlen(hn)
tocttou($heap_214192)' = tocttou(*hn)
$heap_214193' = *myarchname
bytes_after(&$heap_214193)' = strlen(myarchname) + 1
$heap_214193' is allocated by malloc
$heap_214193' is allocated
bytes_before(&$heap_214193)' = 0
strlen(&$heap_214193)' = strlen(myarchname)
tocttou($heap_214193)' = tocttou(*myarchname)
bytes_after(&$heap_214194)' = 120
$heap_214194' is allocated by malloc
bytes_before(&$heap_214194)' = 0
((char*)&$heap_214194)[16]' = 0
((char*)&$heap_214194)[20]' = 0
((char*)&$heap_214194)[116]' = 0
$heap_214195' = &$heap_214195
bytes_after(&$heap_214195)' = 120
$heap_214195' is allocated by malloc
bytes_before(&$heap_214195)' = 0
((char*)&$heap_214195)[16]' = 0
((char*)&$heap_214195)[20]' = 0
((char*)&$heap_214195)[4]' = &$heap_214195
((char*)&$heap_214195)[116]' = 0
bytes_after(&$heap_214196)' = 20
$heap_214196' is allocated by malloc
bytes_before(&$heap_214196)' = 0
((char*)&$heap_214196)[16]' = 0
((char*)&$heap_214196)[8]' = 0
((char*)&$heap_214196)[12]' = 0
$heap_214197' = 0
bytes_after(&$heap_214197)' = 124
$heap_214197' is allocated by malloc
$heap_214197' is freed
bytes_before(&$heap_214197)' = 0
((char*)&$heap_214197)[44]' = pvmmydsig
((char*)&$heap_214197)[52]' = pvmudpmtu
((char*)&$heap_214197)[56]' = 2
((char*)&$heap_214197)[72]' = 1
((char*)&$heap_214197)[76]' = 1
((char*)&$heap_214197)[80]' = &$heap_214198
((char*)&$heap_214197)[8]' = &$heap_214199
((char*)&$heap_214197)[84]' = &$heap_214195
((char*)&$heap_214197)[92]' = &$heap_214194
((char*)&$heap_214197)[100]' = 1
((char*)&$heap_214197)[108]' = 1000
((char*)&$heap_214197)[112]' = &$heap_214196
((char*)&$heap_214197)[12]' = &$heap_214200
$heap_214198' = &$heap_214198
bytes_after(&$heap_214198)' = 120
$heap_214198' is allocated by malloc
bytes_before(&$heap_214198)' = 0
((char*)&$heap_214198)[16]' = 0
((char*)&$heap_214198)[20]' = 0
((char*)&$heap_214198)[4]' = &$heap_214198
((char*)&$heap_214198)[8]' = 0
((char*)&$heap_214198)[116]' = 0
((char*)&$heap_214198)[12]' = 0
$heap_214199' = 112
bytes_after(&$heap_214199)' = 6
$heap_214199' is allocated by malloc
bytes_before(&$heap_214199)' = 0
strlen(&$heap_214199)' = 5
tocttou($heap_214199)' = tocttou(#string167)
$heap_214200' = *myarchname
bytes_after(&$heap_214200)' = strlen(myarchname) + 1
$heap_214200' is allocated by malloc
bytes_before(&$heap_214200)' = 0
strlen(&$heap_214200)' = strlen(myarchname)
tocttou($heap_214200)' = tocttou(*myarchname)
bytes_after(&$heap_214201)' = 8
$heap_214201' is allocated by malloc
bytes_before(&$heap_214201)' = 0
strlen(&$heap_214201)' <= 7
$heap_214202' = &$heap_214201
$heap_214202' is allocated by malloc
$heap_214202' is allocated
bytes_before(&$heap_214202)' = 0
((char*)&$heap_214202)[4]' = 0
bytes_after(&$heap_214203)' = 2
$heap_214203' is allocated by malloc
$heap_214203' is allocated
bytes_before(&$heap_214203)' = 0
strlen(&$heap_214203)' = strlen(&$unknown_764839)
hosts' = &$heap_214186
hp' = ((char*)&((char*)$heap_214186)[28])[4]
p' = &$unknown_764841 + 1
r' = 0
rl' = l'
rm' = 8
s' = 0
s' = &$heap_214203
vn' = &$heap_214203 + 2




Change Warning 22084.28921 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: