Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Null Pointer Dereference  at pvmd.c:3287

Categories: LANG.MEM.NPD CWE:476
Warning ID: 2496.2526
Procedure: loclinput
Trace: View
Modified: Wed Sep 2 12:39:53 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/pvmd.c
   Enter loclinput
 3151 loclinput(tp) 
 3152         struct task *tp;
 3153 {
 3154         struct pkt *pp = 0;
 3155         struct pkt *pp2;
 3156         int n, m;
 3157  
 3158 again: 
 3159         /*
 3160         * if no current packet, start a new one 
 3161         */ 
 3162  
 3163         if (!tp->t_rxp) {
 3164                 tp->t_rxp = pk_new(pvmudpmtu);
 3165 /*
 3166                 tp->t_rxp = pk_new(TDFRAGHDR + 2);
 3167 */ 
 3168                 if (DDFRAGHDR > TDFRAGHDR)
 3169                         tp->t_rxp->pk_dat += DDFRAGHDR - TDFRAGHDR;   /* Unreachable Computation (ID: 2495.2525) */
 3170         }
 3171         pp = tp->t_rxp;
 3172  
 3173         /*
 3174         * read the fragment header and body separately so we can 
 3175         * make a bigger buffer if needed 
 3176         */ 
 3177  
 3178         n = (pp->pk_len < TDFRAGHDR) ? 0 : pvmget32(pp->pk_dat + 8);
 3179         n += TDFRAGHDR - pp->pk_len;
 3180         if (pvmdebmask & PDMPACKET) {
 3181                 pvmlogprintf("loclinput() t%x fr_len=%d fr_dat=+%d n=%d\n",
 3182                                 tp->t_tid, pp->pk_len, pp->pk_dat - pp->pk_buf, n);
 3183         }
 3184 #ifndef WIN32 
 3185         n = read(tp->t_sock, pp->pk_dat + pp->pk_len, n);
 3186 #else 
 3187         n = win32_read_socket(tp->t_sock,pp->pk_dat + pp->pk_len,n); 
 3188 #endif 
 3189         if (pvmdebmask & PDMPACKET) {
 3190                 if (n >= 0) {
 3191                         pvmlogprintf("loclinput() read=%d\n", n);
 3192                 } else 
 3193                         pvmlogperror("loclinput() read");
 3194         }
 3195  
 3196 #ifdef  STATISTICS 
 3197                 switch (n) {
 3198                 case -1: 
 3199                         stats.rdneg++;
 3200                         break;
 3201                 case 0: 
 3202                         stats.rdzer++;
 3203                         break;
 3204                 default: 
 3205                         stats.rdok++;
 3206                         break;
 3207                 }
 3208 #endif 
 3209         if (n == -1) {
 3210                 if (errno != EINTR 
 3211 #ifndef WIN32 
 3212                                 && errno != EWOULDBLOCK 
 3213 #endif 
 3214                 ) {
 3215                         pvmlogperror("loclinput() read");
 3216                         pvmlogprintf("loclinput() marking t%x dead\n",
 3217                                         tp->t_tid);
 3218                         return -1;
 3219                 }
 3220                 return 0;
 3221         }
 3222         if (!n) {
 3223                 if (pvmdebmask & (PDMPACKET|PDMMESSAGE|PDMTASK)) {
 3224                         pvmlogprintf("loclinput() read EOF from t%x sock %d\n",
 3225                                         tp->t_tid, tp->t_sock);
 3226                 }
 3227                 return -1;
 3228         }
 3229  
 3230         if ((pp->pk_len += n) < TDFRAGHDR)
 3231                 return 0;
 3232  
 3233         /*
 3234         * if we have a complete frag, accept it 
 3235         */ 
 3236  
 3237         m = TDFRAGHDR + pvmget32(pp->pk_dat + 8);
 3238         if (pp->pk_len == m) {
 3239                 tp->t_rxp = 0;
 3240                 pp->pk_dst = pvmget32(pp->pk_dat);
 3241 #if defined(IMA_PGON) || defined(IMA_I860) || defined(IMA_CM5) \
 3242                 || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 3243                 || defined(IMA_AIX5SP2) 
 3244                 pp->pk_src = pvmget32(pp->pk_dat + 4); 
 3245 #else 
 3246                 pp->pk_src = tp->t_tid;
 3247 #endif 
 3248                 pp->pk_flag = pvmget8(pp->pk_dat + 12);
   ...
 3264                         pp->pk_len -= MSGHDRLEN;
 3265                         pp->pk_dat += MSGHDRLEN;
 3266                 }
 3267                 if (loclinpkt(tp, pp))
 3268                         return -1;
 3269                 return 0;
 3270         }
 3271  
 3272         /* realloc buffer if frag won't fit */ 
 3273  
 3274         if (pp->pk_len == TDFRAGHDR) {
 3275                 if (m > pp->pk_max - (pp->pk_dat - pp->pk_buf)) {
 3276                         if (!(tp->t_flag & TF_CONN)) {
 3277                                 pvmlogprintf( 
 3278                                         "loclinput() unconnected task sends frag length %d (ha)\n",
 3279                                         m);
 3280                                 return -1;
 3281                         }
 3282                         if (DDFRAGHDR > TDFRAGHDR) {
 3283                                 pp2 = pk_new(m + DDFRAGHDR - TDFRAGHDR);
 3284                                 pp2->pk_dat += DDFRAGHDR - TDFRAGHDR;
 3285                         } else 
true3286                                 pp2 = pk_new(m);
pp2->pk_dat <= 40953287                         BCOPY(pp->pk_dat, pp2->pk_dat, TDFRAGHDR);     /* Null Pointer Dereference */
 3288                         pp2->pk_len = pp->pk_len;
 3289                         pk_free(pp);
 3290                         pp = tp->t_rxp = pp2;
 3291                         if (pvmdebmask & PDMPACKET) {
 3292                                 pvmlogprintf("loclinput() realloc frag max=%d\n", m);
 3293                         }
 3294                 }
 3295                 goto again;
Preconditions
&$unknown_200863 >= 1
&$unknown_200866 = 0
&$unknown_200867 = 16
((char*)$param_1)[48] >= 0
((char*)$param_1)[88] >= 0
$input_1020 >= stats.rdok + 1
$input_1348 = &$unknown_200863
$input_1348 >= 1
Postconditions
((char*)&$unknown_200856)[52]' = 16
atnewline' = 0
$heap_4385' = &$heap_4385
bytes_after(&$heap_4385)' = 184
$heap_4385' is allocated by malloc
$heap_4385' is allocated
bytes_before(&$heap_4385)' = 0
((char*)&$heap_4385)[16]' = 0
((char*)&$heap_4385)[176]' = 0
((char*)&$heap_4385)[24]' = 0
((char*)&$heap_4385)[32]' = 0
((char*)&$heap_4385)[40]' = 0
((char*)&$heap_4385)[8]' = &$heap_4385
m' = 0
n' = &$unknown_200863
pp' = &$unknown_200856
pp2' = &$heap_4385
stats.rdok' = $input_1020 + 1
tmbuf.tm_sec' = &$unknown_200861
tp' = $param_1




Change Warning 2496.2526 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: