Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Null Pointer Dereference  at pvmd.c:4923

Categories: LANG.MEM.NPD CWE:476
Warning ID: 22078.28907
Procedure: mksocs
Trace: view
Modified: Thu Nov 26 11:28:28 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]);
true5500         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  
*hosts->ht_hosts <= 40955531         if (i = mksocs()) {
     Enter slave_config / mksocs
 4834   mksocs() 
 4835   {
 4836           struct hostd *hp = hosts->ht_hosts[hosts->ht_local];   /* Buffer Overrun (ID: 22077.28906) */  /* Buffer Underrun (ID: 22076.28905) */
*hosts->ht_hosts <= 40954837           struct hostd *hp0 = hosts->ht_hosts[0];
 4838           struct sockaddr_in sin;
 4839           char buf[128];
 4840           char *sfn;
 4841   #ifndef WIN32 
 4842           int d;
 4843   #else 
 4844           HANDLE d;
 4845           int e=0; 
 4846   #endif 
 4847   #ifndef NOSOCKOPT 
     ...
 4865   #endif 
 4866   #ifdef IMA_BEOLIN 
 4867           struct hostent *hostaddr; 
 4868   #endif 
 4869           short tmpp;
 4870    
 4871           /*
 4872           * make pvmd-pvmd socket 
 4873           */ 
 4874    
 4875           if ((netsock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
 4876                   pvmlogperror("mksocs() socket netsock");
 4877                   return 1;
 4878           }
 4879    
 4880           p = getenv("PVMNETSOCKPORT");
 4881    
 4882           tmpp = (p) ? atoi(p) : 0;
 4883    
 4884           hp->hd_sad.sin_port = htons(tmpp);
 4885    
 4886           do 
 4887           {
 4888                   oslen = sizeof(hp->hd_sad);
 4889                   if ((cc=bind(netsock, (struct sockaddr*)&hp->hd_sad, oslen)) 
 4890                                   == -1)
 4891                   {
 4892                           if (p) {
 4893                                   tmpp++;
 4894                                   hp->hd_sad.sin_port = htons(tmpp);
 4895                           } else {
 4896                                   pvmlogperror("mksocs() bind netsock");
 4897                                   return 1;
 4898                           }
 4899                   }
 4900           }
 4901           while ( cc == -1 && p && hp->hd_sad.sin_port < 65535 );   /* Redundant Condition (ID: 249.28886) */
 4902    
 4903           if ( cc == -1 ) {
 4904                   pvmlogperror("mksocs() bind netsock");
 4905                   return 1;
 4906           }
 4907    
 4908           oslen = sizeof(hp->hd_sad);   /* Useless Assignment (ID: 248.28885) */
 4909           if (getsockname(netsock, (struct sockaddr*)&hp->hd_sad, &oslen) == -1) {
 4910                   pvmlogperror("mksocs() getsockname netsock");
 4911                   return 1;
 4912           }
 4913    
 4914           /*
 4915           * make pvmd-pvmd' socket 
 4916           */ 
 4917    
 4918           if ((ppnetsock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
 4919                   pvmlogperror("mksocs() socket ppnetsock");
 4920                   return 1;
 4921           }
 4922    
hp0 <= 40954923           hp0->hd_sad.sin_port = 0;     /* Null Pointer Dereference */
     Exit slave_config / mksocs
Preconditions
$param_2 >= 3
((char*)*$param_3)[20] != 58
Postconditions
__x' = 0
ac' = 6
((char*)&$unknown_732141)[56]' = &$unknown_732142
argc' = 6
bad' = 0
cc' = 0
$heap_157744' = 1
bytes_after(&$heap_157744)' = 32
$heap_157744' is allocated by malloc
$heap_157744' is allocated
bytes_before(&$heap_157744)' = 0
((char*)&$heap_157744)[16]' = $input_12
((char*)&$heap_157744)[20]' = $input_95388
((char*)&$heap_157744)[28]' = &$heap_157745
((char*)&$heap_157744)[12]' = $input_12
$heap_157745' = 0
$heap_157745' is allocated
bytes_before(&$heap_157745)' = 0
$heap_157746' = &$heap_157746
bytes_after(&$heap_157746)' = 120
$heap_157746' is allocated by malloc
$heap_157746' is allocated
bytes_before(&$heap_157746)' = 0
((char*)&$heap_157746)[16]' = 0
((char*)&$heap_157746)[20]' = 0
((char*)&$heap_157746)[4]' = &$heap_157746
((char*)&$heap_157746)[8]' = 0
((char*)&$heap_157746)[116]' = 0
((char*)&$heap_157746)[12]' = 0
bytes_after(&$heap_157747)' = 120
$heap_157747' is allocated by malloc
$heap_157747' is allocated
bytes_before(&$heap_157747)' = 0
((char*)&$heap_157747)[16]' = 0
((char*)&$heap_157747)[20]' = 0
((char*)&$heap_157747)[8]' = 0
((char*)&$heap_157747)[116]' = 0
((char*)&$heap_157747)[12]' = 0
$heap_157748' = 1
bytes_after(&$heap_157748)' = 124
$heap_157748' is allocated by malloc
bytes_before(&$heap_157748)' = 0
((char*)&$heap_157748)[52]' = $input_95396
((char*)&$heap_157748)[56]' = 2
((char*)&$heap_157748)[72]' = 1
((char*)&$heap_157748)[76]' = 1
((char*)&$heap_157748)[80]' = &$heap_157746
((char*)&$heap_157748)[8]' = &$heap_157750
((char*)&$heap_157748)[84]' = &$heap_157749
((char*)&$heap_157748)[92]' = &$heap_157747
((char*)&$heap_157748)[100]' = 1
((char*)&$heap_157748)[108]' = 1000
((char*)&$heap_157748)[112]' = 0
$heap_157749' = &$heap_157749
bytes_after(&$heap_157749)' = 120
$heap_157749' is allocated by malloc
$heap_157749' is allocated
bytes_before(&$heap_157749)' = 0
((char*)&$heap_157749)[16]' = 0
((char*)&$heap_157749)[20]' = 0
((char*)&$heap_157749)[4]' = &$heap_157749
((char*)&$heap_157749)[8]' = 0
((char*)&$heap_157749)[116]' = 0
((char*)&$heap_157749)[12]' = 0
$heap_157750' = 63
bytes_after(&$heap_157750)' = 2
$heap_157750' is allocated by malloc
$heap_157750' is allocated
bytes_before(&$heap_157750)' = 0
strlen(&$heap_157750)' = 1
tocttou($heap_157750)' = tocttou(#string176)
bytes_after(&$heap_157751)' = 120
$heap_157751' is allocated by malloc
$heap_157751' is allocated
bytes_before(&$heap_157751)' = 0
((char*)&$heap_157751)[16]' = 0
((char*)&$heap_157751)[20]' = 0
((char*)&$heap_157751)[8]' = 0
((char*)&$heap_157751)[116]' = 0
((char*)&$heap_157751)[12]' = 0
$heap_157752' = 1
bytes_after(&$heap_157752)' = 124
$heap_157752' is allocated by malloc
bytes_before(&$heap_157752)' = 0
((char*)&$heap_157752)[44]' = pvmmydsig
((char*)&$heap_157752)[52]' = pvmudpmtu
((char*)&$heap_157752)[56]' = 2
((char*)&$heap_157752)[72]' = 1
((char*)&$heap_157752)[76]' = 1
((char*)&$heap_157752)[80]' = &$heap_157753
((char*)&$heap_157752)[8]' = &$heap_157756
((char*)&$heap_157752)[84]' = &$heap_157755
((char*)&$heap_157752)[92]' = &$heap_157751
((char*)&$heap_157752)[100]' = 1
((char*)&$heap_157752)[108]' = 1000
((char*)&$heap_157752)[112]' = &$heap_157754
((char*)&$heap_157752)[12]' = &$heap_157757
bytes_after(&$heap_157753)' = 120
$heap_157753' is allocated by malloc
$heap_157753' is allocated
bytes_before(&$heap_157753)' = 0
((char*)&$heap_157753)[16]' = 0
((char*)&$heap_157753)[20]' = 0
((char*)&$heap_157753)[8]' = 0
((char*)&$heap_157753)[116]' = 0
((char*)&$heap_157753)[12]' = 0
bytes_after(&$heap_157754)' = 20
$heap_157754' is allocated by malloc
$heap_157754' is allocated
bytes_before(&$heap_157754)' = 0
((char*)&$heap_157754)[16]' = 0
((char*)&$heap_157754)[8]' = 0
((char*)&$heap_157754)[12]' = 0
$heap_157755' = &$heap_157755
bytes_after(&$heap_157755)' = 120
$heap_157755' is allocated by malloc
$heap_157755' is allocated
bytes_before(&$heap_157755)' = 0
((char*)&$heap_157755)[16]' = 0
((char*)&$heap_157755)[20]' = 0
((char*)&$heap_157755)[4]' = &$heap_157755
((char*)&$heap_157755)[8]' = 0
((char*)&$heap_157755)[116]' = 0
((char*)&$heap_157755)[12]' = 0
$heap_157756' = 112
bytes_after(&$heap_157756)' = 6
$heap_157756' is allocated by malloc
$heap_157756' is allocated
bytes_before(&$heap_157756)' = 0
strlen(&$heap_157756)' = 5
tocttou($heap_157756)' = tocttou(#string167)
$heap_157757' = *myarchname
bytes_after(&$heap_157757)' = strlen(myarchname) + 1
$heap_157757' is allocated by malloc
$heap_157757' is allocated
bytes_before(&$heap_157757)' = 0
strlen(&$heap_157757)' = strlen(myarchname)
tocttou($heap_157757)' = tocttou(*myarchname)
$heap_157758' = &$heap_157758
bytes_after(&$heap_157758)' = 120
$heap_157758' is allocated by malloc
$heap_157758' is allocated
bytes_before(&$heap_157758)' = 0
((char*)&$heap_157758)[16]' = 0
((char*)&$heap_157758)[20]' = 0
((char*)&$heap_157758)[4]' = &$heap_157758
((char*)&$heap_157758)[8]' = 0
((char*)&$heap_157758)[116]' = 0
((char*)&$heap_157758)[12]' = 0
bytes_after(&$heap_157759)' = 120
$heap_157759' is allocated by malloc
$heap_157759' is allocated
bytes_before(&$heap_157759)' = 0
((char*)&$heap_157759)[16]' = 0
((char*)&$heap_157759)[20]' = 0
((char*)&$heap_157759)[8]' = 0
((char*)&$heap_157759)[116]' = 0
((char*)&$heap_157759)[12]' = 0
$heap_157760' = 1
bytes_after(&$heap_157760)' = 124
$heap_157760' is allocated by malloc
bytes_before(&$heap_157760)' = 0
((char*)&$heap_157760)[44]' = pvmmydsig
((char*)&$heap_157760)[52]' = pvmudpmtu
((char*)&$heap_157760)[56]' = 2
((char*)&$heap_157760)[72]' = 1
((char*)&$heap_157760)[76]' = 1
((char*)&$heap_157760)[80]' = &$heap_157758
((char*)&$heap_157760)[8]' = &$heap_157762
((char*)&$heap_157760)[84]' = &$heap_157761
((char*)&$heap_157760)[92]' = &$heap_157759
((char*)&$heap_157760)[100]' = 1
((char*)&$heap_157760)[108]' = 1000
((char*)&$heap_157760)[112]' = 0
((char*)&$heap_157760)[12]' = &$heap_157763
$heap_157761' = &$heap_157761
bytes_after(&$heap_157761)' = 120
$heap_157761' is allocated by malloc
$heap_157761' is allocated
bytes_before(&$heap_157761)' = 0
((char*)&$heap_157761)[16]' = 0
((char*)&$heap_157761)[20]' = 0
((char*)&$heap_157761)[4]' = &$heap_157761
((char*)&$heap_157761)[8]' = 0
((char*)&$heap_157761)[116]' = 0
((char*)&$heap_157761)[12]' = 0
$heap_157762' = *hn
bytes_after(&$heap_157762)' = strlen(hn) + 1
$heap_157762' is allocated by malloc
$heap_157762' is allocated
bytes_before(&$heap_157762)' = 0
strlen(&$heap_157762)' = strlen(hn)
tocttou($heap_157762)' = tocttou(*hn)
$heap_157763' = *myarchname
bytes_after(&$heap_157763)' = strlen(myarchname) + 1
$heap_157763' is allocated by malloc
$heap_157763' is allocated
bytes_before(&$heap_157763)' = 0
strlen(&$heap_157763)' = strlen(myarchname)
tocttou($heap_157763)' = tocttou(*myarchname)
$heap_157764' is allocated by open
$heap_157764' is allocated
$heap_157765' is allocated by open
$heap_157765' is allocated
hosts' = &$heap_157744
hp' = &$unknown_732141
hp' = &$heap_157760
hp0' = 0
i' = argc
lh' = $input_95388
mh' = $input_12
netsock' = &$heap_157764 - 4096
p' = 0
ppnetsock' = &$heap_157765 - 4096
tmpp' = 0




Change Warning 22078.28907 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: