Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Buffer Overrun  at ddpro.c:953

Categories: LANG.MEM.BO CWE:120 CWE:121 CWE:122 CWE:126
Warning ID: 22052.28723
Procedure: addhosts
Trace: view
Modified: Thu Nov 26 11:27:36 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/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: 22059.28730) */
 895         wxp->w_hosts = TALLOC(count, struct hostd *, "waiv");   /* Integer Overflow of Allocation Size (ID: 22058.28729) */
 896         BZERO((char*)wxp->w_hosts, count * sizeof(struct hostd *));   /* Null Pointer Dereference (ID: 22057.28728) */
 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: 22054.28725) */
 908  
 909                 } else {
 910  
 911                 /* Set unspecified fields from hostfile if available */ 
 912  
 913                         if (filehosts &&
 914                                         ((hp2 = nametohost(filehosts, hp->hd_name))   /* Null Pointer Dereference (ID: 22053.28724) */
 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];
$input_8500 < 3948                 if (hp->hd_err)
 949                         continue;
 950  
 951                 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->h_addr_list) < 4953                                         sizeof(struct in_addr));     /* Buffer Overrun */
 954  
 955                 } else {
 956                         if (pvmdebmask & PDMSTARTUP) {
 957                                 pvmlogprintf( 
 958                                                 "start_slaves() can't gethostbyname: %s\n",
 959                                                 hp->hd_name);
 960                         }
 961                         hp->hd_err = PvmNoHost;
 962                         continue;
 963                 }
 964  
 965         /* make sure it's not already configured */ 
 966  
 967                 if (!(hp->hd_flag & HF_OVERLOAD)) {
 968                         for (hh = hosts->ht_last; hh > 0; hh--)
 969                                 if ((hp2 = hosts->ht_hosts[hh]) 
 970                                 && (hp2->hd_sad.sin_addr.s_addr == hp->hd_sad.sin_addr.s_addr)) {
 971                                         hp->hd_err = PvmDupHost;
 972                                         break;
 973                                 }
 974                         if (hp->hd_err)
 975                                 continue;
 976  
 977         /* make sure new ones aren't duplicated */ 
 978  
 979                         for (j = i; j-- > 0; )
 980                                 if (hp->hd_sad.sin_addr.s_addr 
 981                                 == wxp->w_hosts[j]->hd_sad.sin_addr.s_addr) {
 982                                         hp->hd_err = PvmDupHost;
 983                                         break;
 984                                 }
 985                         if (hp->hd_err)
 986                                 continue;
 987                 }
 988  
 989                 ngood++;
Preconditions
&$unknown_371426 >= 3
&$unknown_371429 >= 1
((char*)&$unknown_371432)[48] = 0
((char*)&$unknown_371432)[116] = 0
busyadding = 0
filehosts = 0
$heap_54471 != 0
strlen(&$heap_54471) != 0
$input_12 >= 0
$input_8476 >= 0
$input_8500 >= 0
Postconditions
__x' = 2130706433
((char*)&$unknown_371432)[60]' = $input_8508
buf' = &$heap_54471
busyadding' = 1
count' = &$unknown_371426
he' = &$heap_54474
bytes_after(&$heap_54463)' = 48
$heap_54463' is allocated by malloc
$heap_54463' is allocated
bytes_before(&$heap_54463)' = 0
((char*)&$heap_54463)[16]' = 0
((char*)&$heap_54463)[36]' = 0
((char*)&$heap_54463)[40]' = 0
((char*)&$heap_54463)[44]' = &$heap_54464
((char*)&$heap_54463)[12]' = 3
$heap_54464' = &$unknown_371426
bytes_after(&$heap_54464)' = 8
$heap_54464' is allocated by malloc
$heap_54464' is allocated
bytes_before(&$heap_54464)' = 0
((char*)&$heap_54464)[4]' = &$heap_54465
$heap_54465' = 0
bytes_after(&$heap_54465)' = 4 * &$unknown_371426
$heap_54465' is allocated by malloc
$heap_54465' is allocated
bytes_before(&$heap_54465)' = 0
$heap_54467' = &$heap_54467
bytes_after(&$heap_54467)' = 120
$heap_54467' is allocated by malloc
$heap_54467' is allocated
bytes_before(&$heap_54467)' = 0
((char*)&$heap_54467)[16]' = 0
((char*)&$heap_54467)[20]' = 0
((char*)&$heap_54467)[4]' = &$heap_54467
((char*)&$heap_54467)[8]' = 0
((char*)&$heap_54467)[116]' = 0
((char*)&$heap_54467)[12]' = 0
bytes_after(&$heap_54468)' = 120
$heap_54468' is allocated by malloc
$heap_54468' is allocated
bytes_before(&$heap_54468)' = 0
((char*)&$heap_54468)[16]' = 0
((char*)&$heap_54468)[20]' = 0
((char*)&$heap_54468)[8]' = 0
((char*)&$heap_54468)[116]' = 0
((char*)&$heap_54468)[12]' = 0
bytes_after(&$heap_54469)' = 120
$heap_54469' is allocated by malloc
$heap_54469' is allocated
bytes_before(&$heap_54469)' = 0
((char*)&$heap_54469)[16]' = 0
((char*)&$heap_54469)[20]' = 0
((char*)&$heap_54469)[8]' = 0
((char*)&$heap_54469)[116]' = 0
((char*)&$heap_54469)[12]' = 0
$heap_54470' = 1
bytes_after(&$heap_54470)' = 124
$heap_54470' is allocated by malloc
bytes_before(&$heap_54470)' = 0
((char*)&$heap_54470)[56]' = 2
((char*)&$heap_54470)[72]' = 1
((char*)&$heap_54470)[76]' = 1
((char*)&$heap_54470)[80]' = &$heap_54467
((char*)&$heap_54470)[84]' = &$heap_54468
((char*)&$heap_54470)[92]' = &$heap_54469
((char*)&$heap_54470)[100]' = 1
((char*)&$heap_54470)[112]' = 0
bytes_after(&$heap_54471)' = &$unknown_371429
$heap_54471' is allocated by malloc
$heap_54471' is freed
bytes_before(&$heap_54471)' = 0
$heap_54472' = &$heap_54473
$heap_54472' is a non-heap object
bytes_before(&$heap_54472)' = 0
$heap_54473' = $input_8484
bytes_after(&$heap_54473)' = $input_8476 + 1
$heap_54473' is allocated by malloc
$heap_54473' is a non-heap object
bytes_before(&$heap_54473)' = 0
strlen(&$heap_54473)' = $input_8476
$heap_54474' = &$heap_54475
bytes_after(&$heap_54474)' = 1024
$heap_54474' is a non-heap object
bytes_before(&$heap_54474)' = 0
((char*)&$heap_54474)[16]' = &$heap_54477
((char*)&$heap_54474)[4]' = &$heap_54472
$heap_54475' = $input_444
bytes_after(&$heap_54475)' = $input_12 + 1
$heap_54475' is allocated by malloc
$heap_54475' is a non-heap object
bytes_before(&$heap_54475)' = 0
strlen(&$heap_54475)' = $input_12
$heap_54476' = $input_8508
bytes_after(&$heap_54476)' = $input_8500 + 1
$heap_54476' is allocated by malloc
$heap_54476' is a non-heap object
bytes_before(&$heap_54476)' = 0
strlen(&$heap_54476)' = $input_8500
$heap_54477' = &$heap_54476
$heap_54477' is a non-heap object
bytes_before(&$heap_54477)' = 0
hp' = &$unknown_371432
i' = &$unknown_371426 - 2
last_rv' = &$heap_54474
maxhostid' >= 3
maxhostid' >= &$unknown_371426
wp' = &$heap_54463
wxp' = &$heap_54464




Change Warning 22052.28723 : Buffer Overrun

Priority:
State:
Finding:
Owner:
Note: