Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Buffer Overrun  at ddpro.c:953

Categories: LANG.MEM.BO CWE:120 CWE:121 CWE:122 CWE:126
Warning ID: 2517.2548
Procedure: addhosts
Trace: View
Modified: Wed Sep 2 12:40:07 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
   /u1/paul/SATE/2010/c/pvm/pvm3/src/ddpro.c
   Enter addhosts
 840 addhosts(mp, rmp) 
 841         struct pmsg *mp;        /* the request message */ 
 842         struct pmsg *rmp;       /* reply message blank */ 
 843 {
 844         struct hostd *hp, *hp2;
 845         struct pmsg *mp2;
 846         struct waitc *wp = 0;
 847         struct waitc_add *wxp = 0;
 848         int i, j;
 849         int count;
 850         int ngood;
 851         int ntid;
 852         struct hostent *he;
 853         int maxhostid = (tidhmask >> ffs(tidhmask) - 1);
 854         int hh;
 855         int pid;
 856         int *tids;
 857         char *winpvmdpath;
 858         char *pvmdpath;
 859         char *vmid;
 860         char *buf;
 861         int len;
 862  
 863         /*
 864         * have to lock this for 2 reasons:
 865         *  1. system can't handle overlapping host table updates,
 866         *  2. the new host tids aren't reserved 
 867         */ 
 868         if (busyadding) {
 869 /*
 870                 pvmlogerror("addhosts() already adding new hosts\n");
 871 */ 
 872                 pkint(rmp, PvmAlready);
 873                 sendmessage(rmp);
 874                 return 0;
 875         }
 876  
 877         busyadding = 1;
 878  
 879         /* sanity check count */ 
 880  
 881         if (upkint(mp, &count) || count < 1 || count > maxhostid) {
 882                 pvmlogerror("addhosts() bad msg format\n");
 883                 goto bad;
 884         }
 885  
 886         /*
 887         * make wait context, extract host list from message,
 888         */ 
 889  
 890         wp = wait_new(WT_HOSTSTART);
 891         wp->wa_tid = mp->m_src;
 892         wp->wa_dep = mp->m_wid;
 893         wxp = TALLOC(1, struct waitc_add, "waix");
 894         wxp->w_num = count;   /* Null Pointer Dereference (ID: 2522.2553) */
 895         wxp->w_hosts = TALLOC(count, struct hostd *, "waiv");
 896         BZERO((char*)wxp->w_hosts, count * sizeof(struct hostd *));   /* Null Pointer Dereference (ID: 2521.2552) */
 897         wp->wa_spec = (void *)wxp;
 898  
 899         for (i = 0; i < count; i++) {
 900                 hp = hd_new(0);
 901                 wxp->w_hosts[i] = hp;
 902                 if (upkstralloc(mp, &buf)) {
 903                         pvmlogerror("addhosts() bad msg format\n");
 904                         goto bad;
 905                 }
 906                 if (parsehost(buf, hp)) {
 907                         hp->hd_err = PvmBadParam;   /* Null Pointer Dereference (ID: 2518.2549) */
 908  
 909                 } else {
 910  
 911                 /* Set unspecified fields from hostfile if available */ 
 912  
 913                         if (filehosts &&
 914                                         ((hp2 = nametohost(filehosts, hp->hd_name)) 
 915                                         || (hp2 = filehosts->ht_hosts[0])))
 916                                 applydefaults(hp, hp2);
 917                 }
 918                 PVM_FREE(buf);
 919         }
 920  
 921         /*
 922         * verify we have a chance to add these babies...
 923         * check whether our IP is "real" or just loopback 
 924         */ 
 925  
 926         hp = hosts->ht_hosts[hosts->ht_local];
 927  
 928         if ( hp->hd_sad.sin_addr.s_addr == htonl(0x7f000001) ) {
 929  
 930                 /* damn, we're hosed.  bail on host adds with new */ 
 931                 /* PvmIPLoopback error code... */ 
 932  
 933                 for (i = 0; i < count; i++) {
 934                         hp = wxp->w_hosts[i];
 935                         if (hp->hd_err)
 936                                 continue;
 937                         hp->hd_err = PvmIPLoopback;
 938                 }
 939         }
 940  
 941         /*
 942         * lookup IP addresses  XXX we already have some of them 
 943         */ 
 944  
 945         ngood = 0;
 946         for (i = 0; i < count; i++) {
 947                 hp = wxp->w_hosts[i];
 948                 if (hp->hd_err)
 949                         continue;
 950  
true951                 if (he = gethostbyname(hp->hd_aname ? hp->hd_aname : hp->hd_name)) {
 952                         BCOPY(he->h_addr_list[0], (char*)&hp->hd_sad.sin_addr,
bytes_after(he) < 32953                                         sizeof(struct in_addr));     /* Buffer Overrun */
Preconditions
&$unknown_327068 >= 1
busyadding = 0
((char*)&$heap_19509)[184] = 0
((char*)&$heap_19509)[80] = 0
$heap_19514 != 0
strlen(&$heap_19514) != 0
Postconditions
__x' = 2130706433
buf' = &$heap_19514
busyadding' = 1
count' = 1
ghbn_h_name[0]' = 60
strlen(&ghbn_h_name[0])' = 255
ghbn_h_name[255]' = 0
he' = &stored_hostent.h_name
bytes_after(&$heap_19506)' = 80
$heap_19506' is allocated by malloc
$heap_19506' is allocated
bytes_before(&$heap_19506)' = 0
((char*)&$heap_19506)[20]' = 3
((char*)&$heap_19506)[24]' = 0
((char*)&$heap_19506)[56]' = 0
((char*)&$heap_19506)[64]' = 0
((char*)&$heap_19506)[72]' = &$heap_19507
$heap_19507' = 1
bytes_after(&$heap_19507)' = 16
$heap_19507' is allocated by malloc
$heap_19507' is allocated
bytes_before(&$heap_19507)' = 0
((char*)&$heap_19507)[8]' = &$heap_19508
$heap_19508' = &$heap_19509
bytes_after(&$heap_19508)' = 8
$heap_19508' is allocated by malloc
$heap_19508' is allocated
bytes_before(&$heap_19508)' = 0
strlen(&$heap_19508)' = 0
$heap_19509' = 1
bytes_after(&$heap_19509)' = 200
$heap_19509' is allocated by malloc
$heap_19509' is allocated
bytes_before(&$heap_19509)' = 0
strlen(&$heap_19509)' = 0
((char*)&$heap_19509)[136]' = &$heap_19513
((char*)&$heap_19509)[152]' = 1
((char*)&$heap_19509)[176]' = &$heap_19512
((char*)&$heap_19509)[192]' = &$heap_19515
((char*)&$heap_19509)[88]' = 2
((char*)&$heap_19509)[104]' = 1
((char*)&$heap_19509)[108]' = 1
((char*)&$heap_19509)[112]' = &$heap_19510
((char*)&$heap_19509)[120]' = &$heap_19511
bytes_after(&$heap_19510)' = 184
$heap_19510' is allocated by malloc
$heap_19510' is allocated
bytes_before(&$heap_19510)' = 0
((char*)&$heap_19510)[16]' = 0
((char*)&$heap_19510)[176]' = 0
((char*)&$heap_19510)[24]' = 0
((char*)&$heap_19510)[32]' = 0
((char*)&$heap_19510)[40]' = 0
bytes_after(&$heap_19511)' = 184
$heap_19511' is allocated by malloc
$heap_19511' is allocated
bytes_before(&$heap_19511)' = 0
((char*)&$heap_19511)[16]' = 0
((char*)&$heap_19511)[176]' = 0
((char*)&$heap_19511)[24]' = 0
((char*)&$heap_19511)[32]' = 0
((char*)&$heap_19511)[40]' = 0
$heap_19512' = &$heap_19512
bytes_after(&$heap_19512)' = 32
$heap_19512' is allocated by malloc
$heap_19512' is allocated
bytes_before(&$heap_19512)' = 0
((char*)&$heap_19512)[16]' = 0
((char*)&$heap_19512)[20]' = 0
((char*)&$heap_19512)[24]' = 0
((char*)&$heap_19512)[8]' = &$heap_19512
$heap_19513' = &$heap_19513
bytes_after(&$heap_19513)' = 184
$heap_19513' is allocated by malloc
$heap_19513' is allocated
bytes_before(&$heap_19513)' = 0
((char*)&$heap_19513)[16]' = 0
((char*)&$heap_19513)[176]' = 0
((char*)&$heap_19513)[24]' = 0
((char*)&$heap_19513)[32]' = 0
((char*)&$heap_19513)[40]' = 0
((char*)&$heap_19513)[8]' = &$heap_19513
bytes_after(&$heap_19514)' = &$unknown_327068
$heap_19514' is allocated by malloc
$heap_19514' is freed
bytes_before(&$heap_19514)' = 0
$heap_19515' = *(*filehosts->ht_hosts)->hd_vmid
bytes_after(&$heap_19515)' = strlen((*filehosts->ht_hosts)->hd_vmid) + 1
$heap_19515' is allocated by malloc
$heap_19515' is allocated
bytes_before(&$heap_19515)' = 0
strlen(&$heap_19515)' = strlen((*filehosts->ht_hosts)->hd_vmid)
hp' = &$heap_19509
hp2' = *filehosts->ht_hosts
i' = 0
maxhostid' >= 1
mp' = $param_1
ngood' = 0
rmp' = $param_2
wp' = &$heap_19506
wxp' = &$heap_19507




Change Warning 2517.2548 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: