Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Null Pointer Dereference  at lpvm.c:2475

Categories: LANG.MEM.NPD CWE:476
Warning ID: 22104.29026
Procedure: mroute
Trace: view
Modified: Thu Nov 26 11:29:48 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/lpvm.c
   Enter mroute
 2365 mroute(mid, dtid, tag, tmout) 
 2366         int mid;                                /* message (or 0) */ 
 2367         int dtid;                               /* dest */ 
 2368         int tag;                                /* type tag */ 
 2369         struct timeval *tmout;  /* get at least one message */ 
 2370 {
 2371         static int alreadyhere = 0;     /* have i called myself? */ 
 2372  
 2373         struct ttpcb *pcbp;                     /* pcb for foreign task */ 
 2374         int s;                                          /* socket */ 
 2375         int sbf;                                        /* temp TC_CONREQ message */ 
   ...
 2378         int l;
 2379 #ifdef SOCKLENISUINT 
 2380 #if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2)
 2381         unsigned int oslen;
 2382 #else 
 2383         size_t oslen;
 2384 #endif 
 2385 #else 
 2386         int oslen;
 2387 #endif 
 2388         int cc = 0;
 2389         int gotem = 0;                          /* count of received messages */ 
 2390         static struct timeval ztv = { 0, 0 };
 2391         char *addr = 0;
 2392 #ifndef NOUNIXDOM 
 2393         struct sockaddr_un uns;
 2394         char spath[PVMTMPNAMLEN];
 2395 #endif 
 2396  
 2397         if (up = midtobuf(mid)) {
 2398                 up->m_dst = dtid;
 2399                 up->m_tag = tag;
 2400         }
 2401  
 2402         if (alreadyhere) {
 2403                 if (up) {
 2404                         up->m_ref++;
 2405                         txlist[txwp] = up;
 2406                         if (++txwp >= sizeof(txlist)/sizeof(txlist[0]))
 2407                                 txwp = 0;
 2408                         if (txwp == txrp)
 2409                                 abort();
 2410                 }
 2411  
 2412                 /* we can't wait around if reentered */ 
 2413  
 2414                 if (!tmout || tmout->tv_sec || tmout->tv_usec)
 2415                         return PvmNotImpl;
 2416  
 2417                 return 0;
 2418         }
 2419  
 2420         alreadyhere = 1;
 2421  
 2422         /* if sending a message, decide whether we need to route it. */ 
 2423  
 2424         /* Direct Routing is being set up in this section of code   
 2425      * For workstations (not MPP, SHMEM)  
 2426          *      either Unix domain or TCP sockets are used.
 2427          *  task exit notifies are set up for route closure 
 2428          *
 2429          * For MPPs and SHMEM,
 2430          *      connections to local tasks are always direct and require no 
 2431          *      handshake negotiation.  
 2432         */ 
 2433  
 2434         if (up) {        /*  We've got something to send */ 
 2435  
 2436 #if !defined(IMA_MPP) /* This is the workstation direct route setup */ 
 2437  
 2438                 /* Checks made (Workstation):
 2439                  *      o route option is direct 
 2440                  *      o destination is given 
 2441                  *      o destination is a task 
 2442                  *  o destination is not me 
 2443                  *  o could not find task process control block         
 2444                 */ 
 2445  
 2446                 if (pvmrouteopt == PvmRouteDirect 
 2447                         && dtid 
 2448                         && TIDISTASK(dtid) 
 2449                         && dtid != pvmmytid 
 2450                         && !ttpcb_find(dtid))
 2451                 {
 2452  
 2453 #if !defined(NOUNIXDOM)
 2454                         /* Create a UNIX domain socket to build the direct route */ 
 2455  
 2456                         if ((pvmmytid & TIDHOST) == (dtid & TIDHOST)) {
 2457                                 if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
 2458                                         pvmlogperror("mroute() socket");
 2459  
 2460                                 } else {
 2461                                         BZERO((char*)&uns, sizeof(uns));
 2462                                         uns.sun_family = AF_UNIX;
 2463                                         spath[0] = 0;
 2464                                         (void)PVMTMPNAMFUN(spath);
 2465                                         strcpy(uns.sun_path, spath);   /* Buffer Overrun (ID: 22105.29027) */
 2466  
 2467                                         oslen = sizeof(uns);
 2468                                         if (bind(s, (struct sockaddr*)&uns, oslen) == -1) {
 2469                                                 pvmlogperror("mroute() bind");
 2470                                                 (void)close(s);
 2471                                                 s = -1;
 2472  
 2473                                         } else {
true2474                                                 pcbp = ttpcb_creat(dtid);
pcbp <= 40952475                                                 pcbp->tt_fd = s;     /* Null Pointer Dereference */
Preconditions
mid <= pvmmidhsiz - 1
mid >= 1
dtid != 0
dtid != pvmmytid
ttlist->tt_link->tt_tid != dtid
alreadyhere = 0
pvmmidhsiz >= 2
pvmrouteopt = 3
td = 0
Postconditions
addr' = 0
alreadyhere' = 1
((char*)&$unknown_1207641)[36]' = tag
((char*)&$unknown_1207641)[48]' = dtid
cc' = 0
errno' != 0
f' = f + 1
gotem' = 0
$heap_338364' is allocated by open
$heap_338364' is allocated
oslen' = 110
pcbp' = 0
s' = &$heap_338364 - 4096
spath[0]' = 0
strlen(&spath[0])' = 34
spath[34]' = 0
td' = &#string21[0]
uns.sun_family' = 1
strlen(&uns.sun_family)' = 36
uns.sun_path[0]' = 0
tocttou(uns.sun_path)' = tocttou(spath)
up' = &$unknown_1207641




Change Warning 22104.29026 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: