Text  |   XML   |   Visible Warnings:

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

Categories: LANG.MEM.BO CWE:120 CWE:121 CWE:122 CWE:126
Warning ID: 22085.28922
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++;
 5232                           vn = p;
bytes_after(p) < 15233                           while (isalnum(*p) || *p == '_')     /* Buffer Overrun */  /* 2 more... */
     Exit master_config / varsub
Preconditions
$param_2 = 2
((char*)((char*)((char*)$heap_217346)[28])[4])[24] != 36
((char*)((char*)((char*)$heap_217346)[28])[4])[28] != 0
strlen(((char*)&((char*)((char*)$heap_217346)[28])[4])[28]) != 0
strlen(&$unknown_766027) != 1
strlen(&$unknown_766027) > 0
((char*)&$heap_217357)[20] = 0
((char*)&$heap_217357)[96] >= 0
$heap_217361 != 58
$heap_217363 = 36
((char*)&$heap_217363)[1] = 123
Postconditions
((char*)&((char*)((char*)$heap_217346)[28])[4])[32]' = &$heap_217363
$unknown_766026' is allocated by malloc
atnewline' = 1
debugger' = &$unknown_766026
epaths' = &$heap_217362
errno' != 0
filehosts' = 0
hd' = &#string17[0]
$heap_217346' = 1
bytes_after(&$heap_217346)' = 32
$heap_217346' is allocated by malloc
$heap_217346' is allocated
bytes_before(&$heap_217346)' = 0
((char*)&$heap_217346)[16]' = 1
((char*)&$heap_217346)[20]' = 1
((char*)&$heap_217346)[8]' = ((char*)&$heap_217346)[8] + 1
((char*)&$heap_217346)[12]' = 1
bytes_after(&$heap_217347)' = 120
$heap_217347' is allocated by malloc
$heap_217347' is allocated
bytes_before(&$heap_217347)' = 0
((char*)&$heap_217347)[16]' = 0
((char*)&$heap_217347)[20]' = 0
((char*)&$heap_217347)[8]' = 0
((char*)&$heap_217347)[116]' = 0
((char*)&$heap_217347)[12]' = 0
bytes_after(&$heap_217348)' = 120
$heap_217348' is allocated by malloc
$heap_217348' is allocated
bytes_before(&$heap_217348)' = 0
((char*)&$heap_217348)[16]' = 0
((char*)&$heap_217348)[20]' = 0
((char*)&$heap_217348)[8]' = 0
((char*)&$heap_217348)[116]' = 0
((char*)&$heap_217348)[12]' = 0
bytes_after(&$heap_217349)' = 20
$heap_217349' is allocated by malloc
$heap_217349' is allocated
bytes_before(&$heap_217349)' = 0
((char*)&$heap_217349)[16]' = 0
((char*)&$heap_217349)[8]' = 0
((char*)&$heap_217349)[12]' = 0
$heap_217350' = 1
bytes_after(&$heap_217350)' = 124
$heap_217350' is allocated by malloc
bytes_before(&$heap_217350)' = 0
((char*)&$heap_217350)[44]' = pvmmydsig
((char*)&$heap_217350)[52]' = pvmudpmtu
((char*)&$heap_217350)[56]' = 2
((char*)&$heap_217350)[72]' = 1
((char*)&$heap_217350)[76]' = 1
((char*)&$heap_217350)[80]' = &$heap_217351
((char*)&$heap_217350)[8]' = &$heap_217352
((char*)&$heap_217350)[84]' = &$heap_217348
((char*)&$heap_217350)[92]' = &$heap_217347
((char*)&$heap_217350)[100]' = 1
((char*)&$heap_217350)[108]' = 1000
((char*)&$heap_217350)[112]' = &$heap_217349
((char*)&$heap_217350)[12]' = &$heap_217353
$heap_217351' = &$heap_217351
bytes_after(&$heap_217351)' = 120
$heap_217351' is allocated by malloc
$heap_217351' is allocated
bytes_before(&$heap_217351)' = 0
((char*)&$heap_217351)[16]' = 0
((char*)&$heap_217351)[20]' = 0
((char*)&$heap_217351)[4]' = &$heap_217351
((char*)&$heap_217351)[8]' = 0
((char*)&$heap_217351)[116]' = 0
((char*)&$heap_217351)[12]' = 0
$heap_217352' = *hn
bytes_after(&$heap_217352)' = strlen(hn) + 1
$heap_217352' is allocated by malloc
$heap_217352' is allocated
bytes_before(&$heap_217352)' = 0
strlen(&$heap_217352)' = strlen(hn)
tocttou($heap_217352)' = tocttou(*hn)
$heap_217353' = *myarchname
bytes_after(&$heap_217353)' = strlen(myarchname) + 1
$heap_217353' is allocated by malloc
$heap_217353' is allocated
bytes_before(&$heap_217353)' = 0
strlen(&$heap_217353)' = strlen(myarchname)
tocttou($heap_217353)' = tocttou(*myarchname)
bytes_after(&$heap_217354)' = 120
$heap_217354' is allocated by malloc
bytes_before(&$heap_217354)' = 0
((char*)&$heap_217354)[16]' = 0
((char*)&$heap_217354)[20]' = 0
((char*)&$heap_217354)[116]' = 0
$heap_217355' = &$heap_217355
bytes_after(&$heap_217355)' = 120
$heap_217355' is allocated by malloc
bytes_before(&$heap_217355)' = 0
((char*)&$heap_217355)[16]' = 0
((char*)&$heap_217355)[20]' = 0
((char*)&$heap_217355)[4]' = &$heap_217355
((char*)&$heap_217355)[116]' = 0
bytes_after(&$heap_217356)' = 20
$heap_217356' is allocated by malloc
bytes_before(&$heap_217356)' = 0
((char*)&$heap_217356)[16]' = 0
((char*)&$heap_217356)[8]' = 0
((char*)&$heap_217356)[12]' = 0
$heap_217357' = 0
bytes_after(&$heap_217357)' = 124
$heap_217357' is allocated by malloc
$heap_217357' is freed
bytes_before(&$heap_217357)' = 0
((char*)&$heap_217357)[44]' = pvmmydsig
((char*)&$heap_217357)[52]' = pvmudpmtu
((char*)&$heap_217357)[56]' = 2
((char*)&$heap_217357)[72]' = 1
((char*)&$heap_217357)[76]' = 1
((char*)&$heap_217357)[80]' = &$heap_217358
((char*)&$heap_217357)[8]' = &$heap_217359
((char*)&$heap_217357)[84]' = &$heap_217355
((char*)&$heap_217357)[92]' = &$heap_217354
((char*)&$heap_217357)[100]' = 1
((char*)&$heap_217357)[108]' = 1000
((char*)&$heap_217357)[112]' = &$heap_217356
((char*)&$heap_217357)[12]' = &$heap_217360
bytes_after(&$heap_217358)' = 120
$heap_217358' is allocated by malloc
bytes_before(&$heap_217358)' = 0
((char*)&$heap_217358)[16]' = 0
((char*)&$heap_217358)[20]' = 0
((char*)&$heap_217358)[8]' = 0
((char*)&$heap_217358)[116]' = 0
((char*)&$heap_217358)[12]' = 0
$heap_217359' = 112
bytes_after(&$heap_217359)' = 6
$heap_217359' is allocated by malloc
bytes_before(&$heap_217359)' = 0
strlen(&$heap_217359)' = 5
tocttou($heap_217359)' = tocttou(#string167)
$heap_217360' = *myarchname
bytes_after(&$heap_217360)' = strlen(myarchname) + 1
$heap_217360' is allocated by malloc
bytes_before(&$heap_217360)' = 0
strlen(&$heap_217360)' = strlen(myarchname)
tocttou($heap_217360)' = tocttou(*myarchname)
bytes_after(&$heap_217361)' = 8
$heap_217361' is allocated by malloc
bytes_before(&$heap_217361)' = 0
strlen(&$heap_217361)' <= 7
$heap_217362' = &$heap_217361
$heap_217362' is allocated by malloc
$heap_217362' is allocated
bytes_before(&$heap_217362)' = 0
((char*)&$heap_217362)[4]' = 0
bytes_after(&$heap_217363)' = 2
$heap_217363' is allocated by malloc
$heap_217363' is allocated
bytes_before(&$heap_217363)' = 0
strlen(&$heap_217363)' = strlen(&$unknown_766027)
hosts' = &$heap_217346
hp' = ((char*)&((char*)$heap_217346)[28])[4]
l' = 0
p' = &$heap_217363 + 2
r' = 0
rl' = 0
rm' = 8
s' = 0
s' = &$heap_217363
vn' = &$heap_217363 + 2




Change Warning 22085.28922 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: