Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Negative file descriptor  at host.c:1039

Categories: POSIX.IO.NEGFD
Warning ID: 2606.2640
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 */ 
 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  
true976         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 
   ...
 1028                                                 0xff & (a >> 8),
 1029                                                 0xff & a);
 1030                         }
 1031                 }
 1032         }
 1033  
 1034         *alp = iplist;
 1035         *np = nip;
 1036         return 0;
 1037  
 1038 bail: 
soc <= -11039         (void)close(soc);     /* Negative file descriptor */
Preconditions
iplist != 0
Postconditions
*iplist' is freed
alp' = $param_1
errno' != 0
iplist' = 0
nip' = 0
np' = $param_2
soc' = -1




Change Warning 2606.2640 : Negative file descriptor

Priority:
State:
Finding:
Owner:
Note: