Text  |   XML   |   Visible Warnings:

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

Categories: LANG.MEM.BO CWE:120 CWE:121 CWE:122 CWE:126
Warning ID: 256.28893
Procedure: mksocs
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 mksocs
$input_54052 > 774834 mksocs() 
 4835 {
$input_54076 > 774836         struct hostd *hp = hosts->ht_hosts[hosts->ht_local];   /* Buffer Overrun (ID: 22077.28906) */  /* Buffer Underrun (ID: 22076.28905) */
$input_54100 > 774837         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  
$input_54124 > 774875         if ((netsock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
 4876                 pvmlogperror("mksocs() socket netsock");
 4877                 return 1;
 4878         }
 4879  
$input_54292 > 774880         p = getenv("PVMNETSOCKPORT");
 4881  
$input_54348 > 774882         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  
 4923         hp0->hd_sad.sin_port = 0;   /* Null Pointer Dereference (ID: 22078.28907) */
 4924         oslen = sizeof(hp0->hd_sad);
 4925         if (bind(ppnetsock, (struct sockaddr*)&hp0->hd_sad, oslen) == -1) {
 4926                 pvmlogperror("mksocs() bind ppnetsock");
 4927                 return 1;
 4928         }
 4929         oslen = sizeof(hp0->hd_sad);   /* Useless Assignment (ID: 247.28884) */
 4930         if (getsockname(ppnetsock, (struct sockaddr*)&hp0->hd_sad, &oslen) == -1) {
 4931                 pvmlogperror("mksocs() getsockname ppnetsock");
 4932                 return 1;
 4933         }
 4934  
 4935         /*
 4936         * make pvmd-local task socket 
 4937         */ 
 4938  
 4939 #ifdef NOUNIXDOM 
 4940         if ((loclsock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
   ...
 5022         || setsockopt(ppnetsock, SOL_SOCKET, SO_RCVBUF,
 5023                         (char*)&bsz, sizeof(bsz)) == -1) {
 5024                 pvmlogperror("mksocs() setsockopt");
 5025                 return 1;
 5026         }
 5027 #endif /*NOSOCKOPT*/ 
 5028  
 5029         p = inadport_hex(&sin); 
 5030  
 5031 #else /*NOUNIXDOM*/ 
 5032         if ((loclsock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
 5033                 pvmlogperror("mksocs() socket loclsock");
 5034                 return 1;
 5035         }
 5036  
 5037         BZERO((char*)&uns, sizeof(uns));
 5038         uns.sun_family = AF_UNIX;
$input_12 > 775039         spath[0] = 0;
 5040         (void)PVMTMPNAMFUN(spath);
strlen(&spath[0]) > 1075041         strcpy(uns.sun_path, spath);     /* Buffer Overrun */
Preconditions
$input_12 >= 0
$input_54380 <= 97
$input_54380 >= 0
td = 0
Postconditions
(*hosts->ht_hosts)->hd_sad.sin_family' = &$unknown_706286
(*hosts->ht_hosts)->hd_sad.sin_port' = 0
__v' <= 65534
__x' = $input_54372
((char*)&$unknown_706284)[56]' = &$unknown_706285
((char*)&$unknown_706284)[58]' = __v'
cc' = 0
errno' != 0
f' = f + 1
$heap_82558' is allocated by open
$heap_82558' is allocated
$heap_82559' = $input_444
bytes_after(&$heap_82559)' = $input_12 + 1
$heap_82559' is allocated by malloc
$heap_82559' is a non-heap object
bytes_before(&$heap_82559)' = 0
strlen(&$heap_82559)' = $input_12
$heap_82560' is allocated by open
$heap_82560' is allocated
$heap_82561' is allocated by open
$heap_82561' is allocated
$heap_82562' = $input_54388
bytes_after(&$heap_82562)' = $input_54380 + 1
$heap_82562' is allocated by malloc
$heap_82562' is a non-heap object
bytes_before(&$heap_82562)' = 0
strlen(&$heap_82562)' = $input_54380
hp' = &$unknown_706284
hp0' = *hosts->ht_hosts
loclsock' = &$heap_82561 - 4096
netsock' = &$heap_82558 - 4096
p' = &$heap_82559
ppnetsock' = &$heap_82560 - 4096
spath[0]' = 0
strlen(&spath[0])' = $input_54380 + 30
td' = &$heap_82562
uns.sun_family' = 1
strlen(&uns.sun_family)' = 2
uns.sun_path[0]' = 0
tocttou(uns.sun_path)' = tocttou(spath)




Change Warning 256.28893 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: