Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Leak  at host.c:976

Categories: LANG.ALLOC.LEAK CWE:401 CWE:771 CWE:773
Warning ID: 2604.2638
Procedure: iflist
Trace: View
Modified: Wed Sep 2 12:42: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/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  
referenced by returned value976         if ((soc = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {     /* Leak */
 977                 perror("socket");
 978                 goto bail;
 979         }
 980  
referenced by soc981         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                 }
   ...
 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);
 1030                         }
 1031                 }
 1032         }
 1033  
 1034         *alp = iplist;
 1035         *np = nip;
 1036         return 0;
 1037  
 1038 bail
 1039         (void)close(soc);   /* Negative file descriptor (ID: 2606.2640) */
 1040         return -1;
 1041 } 
Preconditions
iplist = 0
Postconditions
bytes_after(&$heap_39817)' = 40
$heap_39817' is allocated by malloc
$heap_39817' is allocated
bytes_before(&$heap_39817)' = 0
$heap_39818' is allocated by open
$heap_39818' is allocated
((char*)&$heap_39818)[-4096]' is open
((char*)&$heap_39818)[-4096]' is initialized
iplist' = &$heap_39817




Change Warning 2604.2638 : Leak

Priority:
State:
Finding:
Owner:
Note: