Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Null Pointer Dereference  at lpvm.c:1648

Categories: LANG.MEM.NPD CWE:476
Warning ID: 2757.2812
Procedure: mxinput
Trace: View
Modified: Wed Sep 2 12:45:04 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 mxinput
 1545 mxinput(pcbp, nfr) 
 1546         struct ttpcb *pcbp;
 1547         int *nfr;                               /* number of frags read */ 
 1548 {
 1549         int gotem = 0;                  /* num msgs added to pvmrxlist */ 
 1550         struct frag *fp;                /* shadows pcbp->tt_rxf */ 
 1551         struct frag *fp2;
 1552         int n;                                  /* bytes received */ 
 1553         int m;                                  /* length of fragment */ 
 1554         struct pmsg *rxup;              /* message containing this frag */ 
 1555         struct pmsg *hdfrgpile;
 1556         char *cp;                               /* gp */ 
 1557         int src;
 1558         int dst;
 1559         int ff;
 1560         static int fairprobe = 0;
 1561  
 1562         *nfr = 0;
 1563  
 1564  
 1565 #if defined(IMA_MPP) 
 1566  
 1567         /* Messages from Tasks and  Messages from the daemon  are probed 
 1568          * fairprobe makes sure that neither interface gets starved.  
 1569          * fairprobe is toggled when an EOM is found   
 1570         */ 
 1571  
 1572         switch (fairprobe)
   ...
 1584                         if ((fp = pvm_readfrompvmd()) == (struct frag *) NULL)  
 1585                                 fp = pvm_readfrompeer();
 1586                         break;
 1587  
 1588         }
 1589  
 1590         if (!fp)  
 1591                 return gotem;   /* didn't read anything */ 
 1592  
 1593 #else 
 1594         if (!pcbp->tt_rxf)
 1595                 if (!(pcbp->tt_rxf = fr_new(pvmfrgsiz)))   /* Redundant Condition (ID: 2753.2808) */
 1596                         return PvmNoMem;   /* Unreachable Computation (ID: 2754.2809) */
 1597         fp = pcbp->tt_rxf;
 1598  
 1599         /* read fragment header separately from body */ 
 1600  
 1601         n = (fp->fr_len < TDFRAGHDR) ? 0 : pvmget32(fp->fr_dat + 8);
 1602         n += TDFRAGHDR - fp->fr_len;
 1603         if (pvmdebmask & PDMPACKET) {
 1604                 pvmlogprintf("mxinput() pcb t%x fr_len=%d fr_dat=+%d n=%d\n",
 1605                                 pcbp->tt_tid, fp->fr_len, fp->fr_dat - fp->fr_buf, n);
 1606         }
 1607 #ifndef WIN32 
 1608         n = read(pcbp->tt_fd, fp->fr_dat + fp->fr_len, n);   /* Null Pointer Dereference (ID: 2758.2813) */
 1609 #else 
 1610         n = win32_read_socket( pcbp->tt_fd,fp->fr_dat+fp->fr_len,n); 
 1611 #endif 
 1612         if (pvmdebmask & PDMPACKET) {
 1613                 pvmlogprintf("mxinput() read=%d\n", n);
 1614         }
 1615  
 1616         /* deal with errors and closes */ 
 1617  
 1618         if (n == -1 &&  
 1619 #ifndef WIN32 
 1620                         errno != EWOULDBLOCK &&  
 1621 #endif 
 1622                         errno != EINTR)
 1623         {
 1624                 if (pvmdebmask & PDMPACKET) {
 1625                         pvmlogperror("mxinput() read");
 1626                         pvmlogprintf("mxinput() t%x\n", pcbp->tt_tid);
 1627                 }
 1628                 return PvmSysErr;
 1629         }
 1630         if (!n) {
 1631                 if (pvmdebmask & PDMPACKET) {
 1632                         pvmlogprintf("mxinput() t%x read EOF\n", pcbp->tt_tid);
 1633                 }
 1634                 return -1;
 1635         }
 1636  
 1637         if (n < 1)
 1638                 return gotem;
 1639         if ((fp->fr_len += n) < TDFRAGHDR)
 1640                 return gotem;
 1641  
 1642         /* realloc buffer if frag won't fit */ 
 1643  
 1644         m = TDFRAGHDR + pvmget32(fp->fr_dat + 8);
 1645         if (fp->fr_len == TDFRAGHDR) {
 1646                 if (m > fp->fr_max - (fp->fr_dat - fp->fr_buf)) {
true1647                         fp2 = fr_new(m);
fp2->fr_dat <= 40951648                         BCOPY(fp->fr_dat, fp2->fr_dat, TDFRAGHDR);     /* Null Pointer Dereference */
Preconditions
&$unknown_1235206 >= 1
&$unknown_1235210 = 0
&$unknown_1235211 = 0
&$unknown_1235212 = 16
((char*)$param_1)[24] >= 0
((char*)$param_1)[72] = 0
numfrags = 0
pvmfrgsiz = 0
$input_12 = &$unknown_1235206
$input_12 >= 1
Postconditions
((char*)&((char*)$unknown_1235201)[-64])[8]' = ((char*)&$unknown_1235201)[-56]
((char*)$unknown_1235201)[-56]' = ((char*)&$unknown_1235201)[-64]
*stderr' is allocated by fopen
bytes_before(stderr)' = 0
$unknown_1235201' = &freefrags.fr_link
((char*)&$unknown_1235201)[-21]' = 0
((char*)&$unknown_1235201)[-22]' = 1
((char*)&$unknown_1235201)[-24]' = 1
((char*)&$unknown_1235201)[-28]' = 0
((char*)&$unknown_1235201)[-32]' = 0
((char*)&$unknown_1235201)[-40]' = 0
((char*)&$unknown_1235201)[-4]' = 0
((char*)&$unknown_1235201)[-48]' = 0
((char*)&$unknown_1235201)[-56]' = &$unknown_1235201 - 64
((char*)&$unknown_1235201)[-64]' = &$unknown_1235201 - 64
((char*)&$unknown_1235201)[8]' = ((char*)&$unknown_1235200)[8]
fp' = &$unknown_1235201 - 64
fp2' = &$unknown_1235201 - 64
freefrags.fr_link' = &$unknown_1235201 - 64
freefrags.fr_rlink' = &$unknown_1235201
gotem' = 0
m' = 0
n' = &$unknown_1235206
newline' = 0
nfr' = $param_2
numfrags' = 498
pcbp' = $param_1




Change Warning 2757.2812 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: