Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Leak  at lpvmgen.c:3203

Categories: ALLOC.LEAK CWE:401 CWE:771 CWE:773
Warning ID: 389.29093
Procedure: pvm_spawn
Trace: view
Modified: Thu Nov 26 11:31:54 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/lpvmgen.c
   Enter pvm_spawn
 3141 pvm_spawn(file, argv, flags, where, count, tids) 
 3142         char *file;
 3143         char **argv;
 3144         int flags;
 3145         char *where;
 3146         int count;
 3147         int *tids;
 3148 {
 3149         int sbf, rbf;   /* temp for current tx, rx msgs */ 
 3150         int ictx;
 3151         int cc;
 3152         int i, n;
 3153         char **ep;
 3154         int *tidlist = 0;
 3155         char *p;
 3156         char buf[TEV_MASK_LENGTH + 20];
 3157         TEV_DECLS 
 3158  
 3159         if (p = getenv("PVMTASK"))
 3160                 i = pvmstrtoi(p) | flags;
 3161         else 
 3162                 i = flags;
 3163  
 3164         if (TEV_EXCLUSIVE) {
 3165                 if (TEV_DO_TRACE(TEV_SPAWN,TEV_EVENT_ENTRY)) {
 3166                         TEV_PACK_STRING( TEV_DID_SE, TEV_DATA_SCALAR,
 3167                                 file ? file : "", 1, 1 );
 3168                         TEV_PACK_STRING( TEV_DID_SW, TEV_DATA_SCALAR,
 3169                                 where ? where : "", 1, 1 );
 3170                         TEV_PACK_INT( TEV_DID_SF, TEV_DATA_SCALAR, &i, 1, 1 );
 3171                         TEV_PACK_INT( TEV_DID_SC, TEV_DATA_SCALAR, &count, 1, 1 );
 3172                         TEV_FIN;
 3173                 }
 3174         }
 3175  
 3176         if (!(cc = BEATASK)) {
 3177                 if (count < 1)
 3178                         cc = PvmBadParam;
 3179  
 3180                 else {
 3181                         sbf = pvm_setsbuf(pvm_mkbuf(PvmDataFoo));
 3182                         rbf = pvm_setrbuf(0);
 3183  
 3184                         pvm_pkstr(file);
 3185                         pvm_pkint(&i, 1, 1);
 3186                         pvm_pkstr(where ? where : "");
 3187                         pvm_pkint(&count, 1, 1);
 3188                         if (argv)
 3189                                 for (n = 0; argv[n]; n++);
 3190                         else 
 3191                                 n = 0;
 3192                         pvm_pkint(&n, 1, 1);
 3193                         for (i = 0; i < n; i++)
 3194                                 pvm_pkstr(argv[i]);   /* Null Pointer Dereference (ID: 391.29095) */
 3195  
 3196                         pvm_pkint( &(pvmctrc.outtid), 1, 1 );
 3197                         pvm_pkint( &(pvmctrc.outctx), 1, 1 );
 3198                         pvm_pkint( &(pvmctrc.outtag), 1, 1 );
 3199                         pvm_pkint( &(pvmctrc.trctid), 1, 1 );
 3200                         pvm_pkint( &(pvmctrc.trcctx), 1, 1 );
 3201                         pvm_pkint( &(pvmctrc.trctag), 1, 1 );
 3202  
allocated inside call3203                         n = pvmgetenvars(&ep) + 4;     /* Leak */
     Enter pvm_spawn / pvmgetenvars
 3098   pvmgetenvars(ep) 
 3099           char ***ep;
 3100   {
 3101           char **xpl;                     /* vars to export */ 
 3102           int mxpl;                       /* cur length of xpl */ 
 3103           int nxpl;                       /* num vars found */ 
 3104           char buf[200];
 3105           char *p, *q;
 3106           int n;
 3107    
 3108           if (p = getenv("PVM_EXPORT")) {
 3109                   mxpl = 5;
referenced by returned value3110                   xpl = TALLOC(mxpl, char *, "env");
referenced by xpl3111                   xpl[0] = p - 11;   /* Null Pointer Dereference (ID: 388.29092) */
 3112                   nxpl = 1;
 3113                   while (1) {
 3114                           while (*p == ':')
 3115                                   p++;
 3116                           if (!*p)
 3117                                   break;
 3118                           n = (q = CINDEX(p, ':')) ? q - p : strlen(p);
 3119                           strncpy(buf, p, n);   /* No Space For Null Terminator (ID: 22125.29091) */  /* Buffer Overrun (ID: 386.29090) */
 3120                           buf[n] = 0;   /* Buffer Overrun (ID: 385.29089) */
 3121                           if (q = getenv(buf)) {
 3122                                   if (nxpl == mxpl) {
 3123                                           mxpl += mxpl / 2 + 1;
 3124                                           xpl = TREALLOC(xpl, mxpl, char *);   /* Integer Overflow of Allocation Size (ID: 384.29088) */
 3125                                   }
 3126                                   xpl[nxpl++] = q - n - 1;   /* Null Pointer Dereference (ID: 383.29087) */
 3127                           }
 3128                           p += n;
 3129                   }
 3130                   *ep = xpl;
 3131                   return nxpl;
 3132    
 3133           } else {
 3134                   return 0;
 3135           }
 3136   } 
     Exit pvm_spawn / pvmgetenvars
referenced by ep3204                         pvm_pkint(&n, 1, 1);
 3205                         n -= 4;
 3206                         sprintf(buf, "PVMTMASK=%s", pvmctrc.tmask);
 3207                         pvm_pkstr(buf);
 3208                         sprintf(buf, "PVMTRCBUF=%d", pvmctrc.trcbuf);
 3209                         pvm_pkstr(buf);
 3210                         sprintf(buf, "PVMTRCOPT=%d", pvmctrc.trcopt);
 3211                         pvm_pkstr(buf);
 3212                         sprintf(buf, "PVMCTX=0x%x", pvmmyctx);
 3213                         pvm_pkstr(buf);
 3214                         if (n > 0) {
 3215                                 for (i = 0; i < n; i++)
 3216                                         pvm_pkstr(ep[i]);   /* Uninitialized Variable (ID: 390.29094) */
 3217                                 PVM_FREE(ep);
 3218                         }
 3219  
 3220                         if (pvmschedtid)
 3221                                 cc = msendrecv(pvmschedtid, SM_SPAWN, PvmBaseContext);
 3222                         else 
 3223                                 cc = msendrecv(TIDPVMD, TM_SPAWN, SYSCTX_TM);
 3224                         if (cc > 0) {
 3225                                 pvm_upkint(&cc, 1, 1);
 3226                                 if (cc == count) {
 3227                                         tidlist = tids ? tids : TALLOC(count, int, "xxx");
 3228                                         pvm_upkint(tidlist, cc, 1);
 3229                                         cc = bubble(cc, tidlist);
 3230                                 }
 3231                                 pvm_freebuf(pvm_setrbuf(rbf));
 3232  
 3233                         } else 
 3234                                 pvm_setrbuf(rbf);
 3235                         pvm_freebuf(pvm_setsbuf(sbf));
 3236  
 3237                         if (cc > 0) {
 3238                                 sbf = pvm_setsbuf(pvm_mkbuf(PvmDataFoo));
 3239                                 pvm_pkint(&cc, 1, 1);
 3240                                 pvm_pkint(tidlist, cc, 1);
 3241                                 ictx = pvm_setcontext(SYSCTX_TC);
 3242                                 pvmmcast(pvmsbuf->m_mid, tidlist, cc, TC_SIBLINGS);
 3243                                 pvm_setcontext(ictx);
 3244                                 pvm_freebuf(pvm_setsbuf(sbf));
 3245                         }
 3246                 }
 3247         }
 3248  
 3249         if (TEV_AMEXCL) {
 3250                 if (TEV_DO_TRACE(TEV_SPAWN,TEV_EVENT_EXIT)) {
 3251                         int tevcount;
 3252                         TEV_PACK_INT( TEV_DID_CC, TEV_DATA_SCALAR, &cc, 1, 1 );
 3253                         tevcount = ( cc > 0 ) ? cc : 0;
 3254                         TEV_PACK_INT( TEV_DID_STL, TEV_DATA_ARRAY,
 3255                                 tidlist, tevcount, 1 );
 3256                         TEV_FIN;
 3257                 }
 3258                 TEV_ENDEXCL;
 3259         }
 3260  
 3261         if (tidlist != tids && tidlist != NULL)
 3262                 PVM_FREE(tidlist);
 3263  
 3264         if (cc < 0)
 3265                 lpvmerr("pvm_spawn", cc);
 3266         return cc;
 3267 } 
Preconditions
argv = 0
count >= 1
tids = 0
pvmautoerr != 0
pvmautoerr != 2
pvmautoerr != 3
pvmmytid = -1
pvmtoplvl != 0
Postconditions
*stderr' is allocated by fopen
bytes_before(stderr)' = 0
alreadyhere' != 0
pvm_errno' = -24
strlen(&pvmctrc.trctid)' >= 23
pvmmidhsiz' >= 2
pvmmytid' != -1
pvmschedtid' = 0
pvmtrc.trctid' <= 0
txrp' != 0
txwp' = 0




Change Warning 389.29093 : Leak

Priority:
State:
Finding:
Owner:
Note: