Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Integer Overflow of Allocation Size  at host.c:1016

Categories: ALLOC.IOAS BSI:MALLOC-OVERFLOW CWE:680
Warning ID: 190.28815
Procedure: iflist
Trace: view
Modified: Thu Nov 26 11:28: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
   /kat0/fletcher/SATE/2010/pvm3/src/host.c
   Enter iflist
 959 iflist(alp, np) 
 960         struct in_addr **alp;   /* return list of addresses */ 
 961         int *np;                                /* return len of alp */ 
 962 {
 963         int soc = -1;                                           /* socket */ 
 964         static struct in_addr *iplist = 0;      /* list of interface addrs found */ 
 965         int nip = 0;                                            /* length of iplist */ 
 966         char buf[4096];                                         /* return space for SIOCGIOCONF */ 
 967         struct ifconf sif;
 968         struct ifreq *reqp;
 969         struct ifreq req;
 970         char *cp;
 971  
 972         if (iplist)
 973                 PVM_FREE(iplist);
 974         iplist = TALLOC(10, struct in_addr, "ifl");
 975  
 976         if ((soc = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {   /* Leak (ID: 188.28813) */
 977                 perror("socket");
 978                 goto bail;
 979         }
 980  
 981         sif.ifc_ifcu.ifcu_buf = buf;
 982         sif.ifc_len = sizeof(buf);
 983         if (ioctl(soc,
 984 #ifdef OSIOCGIFCONF 
 985 #if defined(IMA_RS6K) || defined(IMA_RS6KMP) || defined(IMA_SP2MPI) \
 986                         || defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) \
 987                         || defined(IMA_FREEBSD)
 988                 SIOCGIFCONF 
 989 #else 
 990                 OSIOCGIFCONF 
 991 #endif 
 992 #else 
 993                 SIOCGIFCONF 
 994 #endif 
 995                 , &sif) == -1) {
 996                 perror("ioctl");
 997                 goto bail;
 998         }
 999  
 1000         for (cp = sif.ifc_ifcu.ifcu_buf;
 1001                         cp - sif.ifc_ifcu.ifcu_buf < sif.ifc_len;
 1002                         cp += sizeof(*reqp) - sizeof(struct sockaddr) + SIZ(reqp->ifr_addr))
 1003         {
 1004                 reqp = (struct ifreq*)cp;
 1005                 if (reqp->ifr_addr.sa_family != AF_INET)
 1006                         continue;
 1007                 BCOPY(reqp->ifr_name, req.ifr_name, sizeof(req.ifr_name));
 1008                 if (ioctl(soc, SIOCGIFFLAGS, &req) == -1) {
 1009                         perror("ioctl");
 1010                         goto bail;
 1011                 }
 1012                 /* On some FreeBSD systems: */ 
 1013                 /* if (IFF_UP & req.ifr_flags) { */ 
 1014                 if (IFF_UP & req.ifr_ifru.ifru_flags) {
 1015                         if (nip > 0 && !(nip % 10))
true1016                                 iplist = TREALLOC(iplist, (nip + 10), struct in_addr);     /* Integer Overflow of Allocation Size */
 1017                         iplist[nip++] = 
 1018                         ((struct sockaddr_in*)(&reqp->ifr_ifru.ifru_addr))->sin_addr;   /* Null Pointer Dereference (ID: 189.28814) */
 1019                         if (pvmdebmask & PDMNET) {
 1020                                 long a;
 1021  
 1022                                 a = ((struct sockaddr_in*)(&reqp->ifr_ifru.ifru_addr))->sin_addr.s_addr;
 1023                                 a = ntohl(a);
 1024                                 pvmlogprintf("iflist() %s %d.%d.%d.%d\n",
 1025                                                 reqp->ifr_name,
 1026                                                 0xff & (a >> 24),
 1027                                                 0xff & (a >> 16),
 1028                                                 0xff & (a >> 8),
 1029                                                 0xff & a);
Preconditions
&$unknown_689927 >= &$unknown_689928
&$unknown_689929 >= 1
((char*)&$unknown_689927)[48] = 2
iplist != 0
Postconditions
*iplist' is freed
cp' = &$unknown_689927 + 32
bytes_before(&$heap_71792)' = 0
$heap_71793' is allocated by open
$heap_71793' is allocated
nip' = &$unknown_689929
reqp' = &$unknown_689927 + 32
sif.ifc_ifcu' = &$unknown_689928
soc' = &$heap_71793 - 4096




Change Warning 190.28815 : Integer Overflow of Allocation Size

Priority:
State:
Finding:
Owner:
Note: