Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Leak  at lpvm.c:1282

Categories: LANG.ALLOC.LEAK CWE:401 CWE:771 CWE:773
Warning ID: 2822.2882
Procedure: pvm_tc_conreq
Trace: View
Modified: Wed Sep 2 12:48:55 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/lpvm.c
   Enter pvm_tc_conreq
 1132 pvm_tc_conreq(mid) 
 1133         int mid;
 1134 {
 1135         int src;                                        /* sender of request */ 
 1136         int sbf = 0;                            /* reply message mid */ 
 1137         int ttpro;                                      /* protocol revision */ 
 1138         struct ttpcb *pcbp;                     /* pcb for connection */ 
 1139         int ackd;                                       /* allow connection (0) */ 
 1140         char *addr = "";                        /* socket address */ 
 1141         int i;
 1142         int ictx;
 1143 #ifdef SOCKLENISUINT 
 1144 #if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2)
 1145         unsigned int oslen;
 1146 #else 
 1147         size_t oslen;
 1148 #endif 
 1149 #else 
 1150         int oslen;
 1151 #endif 
 1152 #ifndef NOUNIXDOM 
 1153         struct sockaddr_un uns;
 1154         char spath[PVMTMPNAMLEN];
 1155 #endif 
 1156         char buf[256];
 1157  
 1158         pvm_bufinfo(mid, (int *)0, (int *)0, &src);
 1159  
 1160         pvm_upkint(&ttpro, 1, 1);
 1161         pvm_upkstr(buf);
 1162  
 1163         if (pcbp = ttpcb_find(src)) {   /* Uninitialized Variable (ID: 2827.2888) */
 1164                 if (pvmdebmask & PDMROUTE) {
 1165                         pvmlogprintf( 
 1166                                         "pvm_tc_conreq() crossed CONREQ from t%x\n", src);
 1167                 }
 1168                 if (pcbp->tt_state == TTCONWAIT) {
 1169  
 1170                         /* must handle simultaneous connect from both ends:
 1171                          *  lower tid of the two just ignores the CONREQ.
 1172                          *  higher tid pretends it didn't send a CONREQ,
 1173                          *      sends a CONACK back.
   ...
 1214                                         pvm_freebuf(pvm_setsbuf(sbf));
 1215                                 }
 1216                         }
 1217  
 1218                 } else {
 1219                         pvmlogprintf( 
 1220                                         "pvm_tc_conreq() CONREQ from t%x but state=%d ?\n",
 1221                                         src, pcbp->tt_state);
 1222                 }
 1223  
 1224         } else {
 1225                 if (pvmdebmask & PDMROUTE)
 1226                         pvmlogprintf("pvm_tc_conreq() CONREQ from t%x\n", src);
 1227                 ackd = 1;
 1228                 pcbp = ttpcb_creat(src);
 1229                 if (pvmrouteopt != PvmDontRoute) {
 1230                         if (buf[0] == '/') {   /* Uninitialized Variable (ID: 2825.2887) */
 1231  
 1232 #ifdef NOUNIXDOM 
 1233  
 1234                                 pvmlogprintf( "%s CONREQ from t%x, ",
 1235                                                 "pvm_tc_conreq()", src );
 1236                                 pvmlogprintf( "Unix domain socket unsupported\n" ); 
 1237  
 1238 #else /*NOUNIXDOM*/ 
 1239  
 1240                                 if ((pcbp->tt_fd = socket(AF_UNIX, SOCK_STREAM, 0))   /* Null Pointer Dereference (ID: 2826.2886) */
   ...
 1271                                                         /* new route socket listening, */ 
 1272                                                         /* will be accepted later */ 
 1273  
 1274                                                         check_routeadd(pcbp);
 1275                                                 }
 1276                                         }
 1277                                 }
 1278  
 1279 #endif /*NOUNIXDOM*/ 
 1280  
 1281                         } else {
referenced by returned value1282                                 if ((pcbp->tt_fd = socket(AF_INET, SOCK_STREAM, 0))     /* Leak */
referenced by pcbp->tt_fd1283                                                 == -1) {
 1284                                         pvmlogperror("pvm_tc_conreq() socket");
 1285  
 1286                                 } else {
 1287                                         pcbp->tt_sad = pvmourinet;
 1288                                         oslen = sizeof(pcbp->tt_sad);
referenced by ((char*)&pcbp[-1].tt_spath)[4]1289                                         if (bind(pcbp->tt_fd,
referenced by pcbp->tt_fd1290                                                         (struct sockaddr*)&pcbp->tt_sad, oslen) 
referenced by ((char*)&pcbp[-1].tt_spath)[4]1291                                                                 == -1) {
 1292                                                 pvmlogperror("pvm_tc_conreq() bind");
 1293  
 1294                                         } else {
 1295                                                 if (getsockname(pcbp->tt_fd,
 1296                                                                 (struct sockaddr*)&pcbp->tt_sad, &oslen
 1297                                                                         == -1) {
 1298                                                         pvmlogperror("pvm_tc_conreq() getsockname");
 1299  
 1300                                                 } else {
 1301                                                         if (listen(pcbp->tt_fd, 1) == -1)
 1302                                                                 pvmlogperror("pvm_tc_conreq() listen");
   ...
 1318                                                                 /* will be accepted later */ 
 1319  
 1320                                                                 check_routeadd(pcbp);
 1321                                                         }
 1322                                                 }
 1323                                         }
 1324                                 }
 1325                         }
 1326                 }
 1327  
referenced by pcbp->tt_fd1328                 if (pvmdebmask & PDMROUTE)
 1329                         pvmlogprintf( "%s: sending CONACK to t%x\n",
 1330                                 "pvm_tc_conreq()", src );
 1331  
 1332                 sbf = pvm_setsbuf(pvm_mkbuf(PvmDataFoo));
 1333                 ttpro = TDPROTOCOL;
 1334                 pvm_pkint(&ttpro, 1, 1);
 1335                 pvm_pkint(&ackd, 1, 1);
 1336                 pvm_pkstr(addr);
 1337                 i = pvmrescode;
 1338                 pvmrescode = 1;
 1339                 ictx = pvm_setcontext(SYSCTX_TC);
 1340                 pvm_send(src, TC_CONACK);
 1341                 pvm_setcontext(ictx);
 1342                 pvmrescode = i;
 1343                 pvm_freebuf(pvm_setsbuf(sbf));
 1344  
 1345                 if (ackd)
 1346                         ttpcb_delete(pcbp);
 1347         }
 1348         pvm_freebuf(mid);
 1349         return 0;
 1350 } 
Preconditions
$param_1 >= 1
pvmautoerr != 0
pvmautoerr != 2
pvmautoerr != 3
pvmrouteopt != 1
pvmtoplvl != 0
Postconditions
*stderr' is allocated by fopen
bytes_before(stderr)' = 0
pvm_errno' = -2
pvmmidhsiz' >= 2
pvmmidhsiz' >= $param_1 + 1




Change Warning 2822.2882 : Leak

Priority:
State:
Finding:
Owner:
Note: