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: 22068.28897
Procedure: varsub
Trace: view
Modified: Thu Nov 26 11:28:24 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 slave_config
 5449 slave_config(hn, argc, argv) 
 5450         char *hn;
 5451         int argc;
 5452         char **argv;
 5453 {
 5454         int lh;                 /* local host index */ 
 5455         int mh;                 /* master host index */ 
 5456         struct hostd *hp;
 5457         int i, j;
 5458         int ac;
 5459         int ms = 0;             /* manual (humanoid) startup */ 
 5460 #ifndef WIN32 
 5461         int dof = 1;            /* fork, exit parent (default) */ 
 5462 #else 
 5463         int dof = 0; 
 5464 #endif 
 5465         int bad = 0;
 5466         char *p;
 5467         char *s;
 5468  
 5469         for (i = j = ac = 1; i < argc; i++) {
 5470                 if (argv[i][0] == '-') {
 5471                         switch (argv[i][1]) {
 5472  
 5473                         case 'S': 
 5474                                 ms = 1;
 5475                                 break;
 5476  
 5477                         case 'f': 
 5478                                 dof = 0;
 5479                                 break;
 5480  
 5481                         default: 
 5482                                 pvmlogprintf("slave_config() unknown switch: %s\n", argv[i]);
 5483                                 bad++;
 5484                         }
 5485  
 5486                 } else {
 5487                         argv[j++] = argv[i];
 5488                         ac++;
 5489                 }
 5490         }
 5491         argc = ac;
 5492  
 5493         if (bad || argc != 6) {
 5494                 pvmlogerror("slave_config: bad args\n");
 5495                 pvmbailout(0);
 5496         }
 5497  
 5498         mh = atoi(argv[1]);
 5499         lh = atoi(argv[4]);
 5500         hosts = ht_new(1);
 5501         hosts->ht_serial = 1;
 5502         hosts->ht_master = mh;
 5503         hosts->ht_cons = mh;
 5504         hosts->ht_local = lh;
 5505  
 5506         hp = hd_new(mh);
 5507         hp->hd_name = STRALLOC("?");   /* Null Pointer Dereference (ID: 262.28915) */
 5508         hex_inadport(argv[2], &hp->hd_sad);
 5509         hp->hd_mtu = atoi(argv[3]);
 5510         ht_insert(hosts, hp);
 5511         hd_unref(hp);
 5512  
 5513         hp = hd_new(0);
 5514         hp->hd_name = STRALLOC("pvmd'");   /* Null Pointer Dereference (ID: 261.28913) */
 5515         hp->hd_arch = STRALLOC(myarchname);   /* Null Pointer Dereference (ID: 260.28911) */
 5516         hp->hd_mtu = pvmudpmtu;
 5517         hp->hd_dsig = pvmmydsig;
 5518         hex_inadport(argv[5], &hp->hd_sad);
 5519         ht_insert(hosts, hp);
 5520         hd_unref(hp);
 5521  
 5522         hp = hd_new(lh);
 5523         hp->hd_name = STRALLOC(hn);   /* Null Pointer Dereference (ID: 259.28909) */
 5524         hp->hd_arch = STRALLOC(myarchname);   /* Null Pointer Dereference (ID: 260.28908) */
 5525         hp->hd_mtu = pvmudpmtu;
 5526         hp->hd_dsig = pvmmydsig;
 5527         hex_inadport(argv[5], &hp->hd_sad);
 5528         ht_insert(hosts, hp);
 5529         hd_unref(hp);
 5530  
 5531         if (i = mksocs()) {
 5532                 if (i == 2) {
 5533                         printf("PvmDupHost\n");
 5534                         fflush(stdout);
 5535                 }
 5536                 pvmbailout(0);
 5537         }
 5538  
 5539         printf("ddpro<%d> arch<%s> ip<%s> mtu<%d> dsig<%d>\n",
 5540                 DDPROTOCOL,
 5541                 myarchname,
 5542                 inadport_hex(&hp->hd_sad),
 5543                 pvmudpmtu,
 5544                 pvmmydsig);
 5545         fflush(stdout);
 5546  
 5547 #ifndef WIN32 
 5548  
 5549 #if !defined(IMA_OS2) && !defined(CYGWIN)
 5550         if (!ms)
 5551                 (void)read(0, (char*)&i, 1);
 5552 #endif 
 5553  
 5554         if (dof) {
 5555                 if (i = fork()) {
 5556                         if (i == -1)
 5557                                 pvmlogperror("slave_config() fork");
 5558                         exit(0);
 5559                 }
 5560  
 5561         /* close everything but our sockets */ 
 5562  
 5563                 for (i = getdtablesize(); --i >= 0; )
 5564 /* XXX don't like this - hard to maintain */ 
 5565                         if (i != netsock && i != loclsock && i != log_fd)
 5566                                 (void)close(i);
 5567         }
 5568  
 5569         /* reopen 0, 1, 2*/ 
 5570  
 5571         (void)open("/dev/null", O_RDONLY, 0);
 5572         (void)open("/dev/null", O_WRONLY, 0);   /* File System Race Condition (ID: 22074.28903) */
 5573         (void)dup2(1, 2);
 5574  
 5575 #endif 
 5576  
 5577         pvmsetlog(2);
 5578  
 5579         if ((p = getenv("PVM_PATH")))
 5580                 s = STRALLOC(p);   /* Null Pointer Dereference (ID: 22072.28901) */
 5581         else 
 5582                 s = STRALLOC(DEFBINDIR);   /* Null Pointer Dereference (ID: 22073.28902) */
 5583         epaths = colonsep(varsub(s));
 5584         PVM_FREE(s);
 5585  
 5586         s = STRALLOC(DEFDEBUGGER);   /* Null Pointer Dereference (ID: 22071.28900) */
 5587         debugger = varsub(s);
 5588         PVM_FREE(s);
 5589  
 5590         if ((s = getenv("PVM_WD")))
 5591                 p = STRALLOC(s);   /* Null Pointer Dereference (ID: 22070.28899) */
 5592         else 
true5593                 p = STRALLOC(pvmgethome());   /* Null Pointer Dereference (ID: 22069.28898) */
bytes_after(p) < 35594         s = varsub(p);
     Enter slave_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 slave_config / varsub
Preconditions
$param_2 >= 3
&$unknown_719881 != 0
((char*)*$param_3)[20] != 58
((char*)*$param_3)[8] != 58
$unknown_719883 != 58
strlen(&$unknown_719885) != 1
strlen(&$unknown_719885) > 0
((char*)&$heap_98737)[20] != 0
((char*)&$heap_98737)[96] >= 0
$heap_98753 = 36
((char*)&$heap_98753)[1] = 123
Postconditions
((char*)$heap_98737)[20]' is freed
*stdout' is allocated by fopen
bytes_before(stdout)' = 0
ac' = 6
argc' = 6
atnewline' = 1
bad' = 0
strlen(&buf[0])' = 17
buf[17]' = 0
debugger' = &$unknown_719884
dof' = &$unknown_719881
epaths' = &$heap_98751
errno' != 0
hd' = &#string17[0]
$heap_98729' = 1
bytes_after(&$heap_98729)' = 32
$heap_98729' is allocated by malloc
$heap_98729' is allocated
bytes_before(&$heap_98729)' = 0
((char*)&$heap_98729)[16]' = $input_12
((char*)&$heap_98729)[20]' = $input_68564
((char*)&$heap_98729)[12]' = $input_12
$heap_98731' = &$heap_98731
bytes_after(&$heap_98731)' = 120
$heap_98731' is allocated by malloc
$heap_98731' is allocated
bytes_before(&$heap_98731)' = 0
((char*)&$heap_98731)[16]' = 0
((char*)&$heap_98731)[20]' = 0
((char*)&$heap_98731)[4]' = &$heap_98731
((char*)&$heap_98731)[8]' = 0
((char*)&$heap_98731)[116]' = 0
((char*)&$heap_98731)[12]' = 0
bytes_after(&$heap_98732)' = 120
$heap_98732' is allocated by malloc
$heap_98732' is allocated
bytes_before(&$heap_98732)' = 0
((char*)&$heap_98732)[16]' = 0
((char*)&$heap_98732)[20]' = 0
((char*)&$heap_98732)[8]' = 0
((char*)&$heap_98732)[116]' = 0
((char*)&$heap_98732)[12]' = 0
$heap_98733' = 1
bytes_after(&$heap_98733)' = 124
$heap_98733' is allocated by malloc
bytes_before(&$heap_98733)' = 0
((char*)&$heap_98733)[52]' = $input_68572
((char*)&$heap_98733)[56]' = 2
((char*)&$heap_98733)[72]' = 1
((char*)&$heap_98733)[76]' = 1
((char*)&$heap_98733)[80]' = &$heap_98731
((char*)&$heap_98733)[8]' = &$heap_98735
((char*)&$heap_98733)[84]' = &$heap_98734
((char*)&$heap_98733)[92]' = &$heap_98732
((char*)&$heap_98733)[100]' = 1
((char*)&$heap_98733)[108]' = 1000
((char*)&$heap_98733)[112]' = 0
$heap_98734' = &$heap_98734
bytes_after(&$heap_98734)' = 120
$heap_98734' is allocated by malloc
$heap_98734' is allocated
bytes_before(&$heap_98734)' = 0
((char*)&$heap_98734)[16]' = 0
((char*)&$heap_98734)[20]' = 0
((char*)&$heap_98734)[4]' = &$heap_98734
((char*)&$heap_98734)[8]' = 0
((char*)&$heap_98734)[116]' = 0
((char*)&$heap_98734)[12]' = 0
$heap_98735' = 63
bytes_after(&$heap_98735)' = 2
$heap_98735' is allocated by malloc
$heap_98735' is allocated
bytes_before(&$heap_98735)' = 0
strlen(&$heap_98735)' = 1
tocttou($heap_98735)' = tocttou(#string176)
bytes_after(&$heap_98736)' = 120
$heap_98736' is allocated by malloc
bytes_before(&$heap_98736)' = 0
$heap_98737' = 0
bytes_after(&$heap_98737)' = 124
$heap_98737' is allocated by malloc
$heap_98737' is freed
bytes_before(&$heap_98737)' = 0
((char*)&$heap_98737)[44]' = pvmmydsig
((char*)&$heap_98737)[52]' = pvmudpmtu
((char*)&$heap_98737)[56]' = 2
((char*)&$heap_98737)[72]' = 1
((char*)&$heap_98737)[76]' = 1
((char*)&$heap_98737)[80]' = &$heap_98736
((char*)&$heap_98737)[8]' = &$heap_98740
((char*)&$heap_98737)[84]' = &$heap_98738
((char*)&$heap_98737)[92]' = &$heap_98739
((char*)&$heap_98737)[100]' = 1
((char*)&$heap_98737)[108]' = 1000
((char*)&$heap_98737)[112]' = 0
((char*)&$heap_98737)[12]' = &$heap_98741
$heap_98738' = &$heap_98738
bytes_after(&$heap_98738)' = 120
$heap_98738' is allocated by malloc
bytes_before(&$heap_98738)' = 0
((char*)&$heap_98738)[16]' = 0
((char*)&$heap_98738)[20]' = 0
((char*)&$heap_98738)[4]' = &$heap_98738
((char*)&$heap_98738)[116]' = 0
bytes_after(&$heap_98739)' = 120
$heap_98739' is allocated by malloc
bytes_before(&$heap_98739)' = 0
((char*)&$heap_98739)[16]' = 0
((char*)&$heap_98739)[20]' = 0
((char*)&$heap_98739)[116]' = 0
$heap_98740' = 112
bytes_after(&$heap_98740)' = 6
$heap_98740' is allocated by malloc
bytes_before(&$heap_98740)' = 0
strlen(&$heap_98740)' = 5
tocttou($heap_98740)' = tocttou(#string167)
$heap_98741' = *myarchname
bytes_after(&$heap_98741)' = strlen(myarchname) + 1
$heap_98741' is allocated by malloc
bytes_before(&$heap_98741)' = 0
strlen(&$heap_98741)' = strlen(myarchname)
tocttou($heap_98741)' = tocttou(*myarchname)
bytes_after(&$heap_98742)' = 120
$heap_98742' is allocated by malloc
$heap_98742' is allocated
bytes_before(&$heap_98742)' = 0
((char*)&$heap_98742)[16]' = 0
((char*)&$heap_98742)[20]' = 0
((char*)&$heap_98742)[8]' = 0
((char*)&$heap_98742)[116]' = 0
((char*)&$heap_98742)[12]' = 0
$heap_98743' = &$heap_98743
bytes_after(&$heap_98743)' = 120
$heap_98743' is allocated by malloc
$heap_98743' is allocated
bytes_before(&$heap_98743)' = 0
((char*)&$heap_98743)[16]' = 0
((char*)&$heap_98743)[20]' = 0
((char*)&$heap_98743)[4]' = &$heap_98743
((char*)&$heap_98743)[8]' = 0
((char*)&$heap_98743)[116]' = 0
((char*)&$heap_98743)[12]' = 0
$heap_98744' = &$heap_98744
bytes_after(&$heap_98744)' = 120
$heap_98744' is allocated by malloc
$heap_98744' is allocated
bytes_before(&$heap_98744)' = 0
((char*)&$heap_98744)[16]' = 0
((char*)&$heap_98744)[20]' = 0
((char*)&$heap_98744)[4]' = &$heap_98744
((char*)&$heap_98744)[8]' = 0
((char*)&$heap_98744)[116]' = 0
((char*)&$heap_98744)[12]' = 0
$heap_98745' = 1
bytes_after(&$heap_98745)' = 124
$heap_98745' is allocated by malloc
bytes_before(&$heap_98745)' = 0
((char*)&$heap_98745)[44]' = pvmmydsig
((char*)&$heap_98745)[52]' = pvmudpmtu
((char*)&$heap_98745)[56]' = 2
((char*)&$heap_98745)[72]' = 1
((char*)&$heap_98745)[76]' = 1
((char*)&$heap_98745)[80]' = &$heap_98743
((char*)&$heap_98745)[8]' = &$heap_98747
((char*)&$heap_98745)[84]' = &$heap_98744
((char*)&$heap_98745)[92]' = &$heap_98742
((char*)&$heap_98745)[100]' = 1
((char*)&$heap_98745)[108]' = 1000
((char*)&$heap_98745)[112]' = &$heap_98746
((char*)&$heap_98745)[12]' = &$heap_98748
bytes_after(&$heap_98746)' = 20
$heap_98746' is allocated by malloc
$heap_98746' is allocated
bytes_before(&$heap_98746)' = 0
((char*)&$heap_98746)[16]' = 0
((char*)&$heap_98746)[8]' = 0
((char*)&$heap_98746)[12]' = 0
$heap_98747' = *hn
bytes_after(&$heap_98747)' = strlen(hn) + 1
$heap_98747' is allocated by malloc
$heap_98747' is allocated
bytes_before(&$heap_98747)' = 0
strlen(&$heap_98747)' = strlen(hn)
tocttou($heap_98747)' = tocttou(*hn)
$heap_98748' = *myarchname
bytes_after(&$heap_98748)' = strlen(myarchname) + 1
$heap_98748' is allocated by malloc
$heap_98748' is allocated
bytes_before(&$heap_98748)' = 0
strlen(&$heap_98748)' = strlen(myarchname)
tocttou($heap_98748)' = tocttou(*myarchname)
$heap_98749' is allocated by open
$heap_98749' is allocated
$heap_98750' = 36
bytes_after(&$heap_98750)' = 49
$heap_98750' is allocated by malloc
$heap_98750' is freed
bytes_before(&$heap_98750)' = 0
tocttou($heap_98750)' = tocttou(#string168)
$heap_98751' = &$unknown_719883
$heap_98751' is allocated by malloc
$heap_98751' is allocated
bytes_before(&$heap_98751)' = 0
((char*)&$heap_98751)[4]' = 0
$heap_98752' = 36
bytes_after(&$heap_98752)' = 23
$heap_98752' is allocated by malloc
$heap_98752' is freed
bytes_before(&$heap_98752)' = 0
tocttou($heap_98752)' = tocttou(#string170)
bytes_after(&$heap_98753)' = 2
$heap_98753' is allocated by malloc
$heap_98753' is allocated
bytes_before(&$heap_98753)' = 0
strlen(&$heap_98753)' = strlen(&$unknown_719885)
hosts' = &$heap_98729
hp' = &$heap_98745
i' = -1
l' = 0
lh' = $input_68564
log_ff' = 0
log_how' = 2
mh' = $input_12
ms' = 1
p' = &$heap_98753 + 2
p' = &$heap_98753
r' = 0
rl' = 0
rm' = 8
s' = 0
s' = &$heap_98753
vn' = &$heap_98753 + 2




Change Warning 22068.28897 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: