Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Null Pointer Dereference  at host.c:1018

Categories: LANG.MEM.NPD CWE:476
Warning ID: 2605.2639
Procedure: iflist
Trace: View
Modified: Wed Sep 2 12:42:08 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/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 */ 
true965         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);
nip <= 0974         iplist = TALLOC(10, struct in_addr, "ifl");
 975  
 976         if ((soc = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {   /* Leak (ID: 2604.2638) */
 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))
 1016                                 iplist = TREALLOC(iplist, (nip + 10), struct in_addr);
 1017                         iplist[nip++] = 
iplist <= 40951018                         ((struct sockaddr_in*)(&reqp->ifr_ifru.ifru_addr))->sin_addr;     /* Null Pointer Dereference */
Preconditions
buf[16] = 2
iplist != 0
Postconditions
*iplist' is freed
alp' = $param_1
buf[0]' = req.ifr_ifrn
cp' = &buf[0]
$heap_39850' is allocated by open
$heap_39850' is allocated
((char*)&$heap_39850)[-4096]' is open
((char*)&$heap_39850)[-4096]' is initialized
iplist' = 0
nip' = 1
np' = $param_2
reqp' = &buf[0]
sif.ifc_ifcu' = &buf[0]
soc' = &$heap_39850 - 4096




Change Warning 2605.2639 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: