Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Uninitialized Variable  at lpvm.c:3392

Categories: LANG.MEM.UVAR CWE:457
Warning ID: 22106.29033
Procedure: pvmbeatask
Trace: view
Modified: Thu Nov 26 11:29:56 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 pvmbeatask
true2999 pvmbeatask() 
 3000 {
 3001         int sbf = 0, rbf = 0;                   /* saved rx and tx message handles */ 
 3002         int prver;                                              /* protocol version */ 
 3003         int cookie;                                             /* cookie assigned by pvmd for ident */ 
 3004         int cc;
 3005         char **ep=0;
 3006         char authfn[PVMTMPNAMLEN];      /* auth file name */ 
 3007         int authfd = -1;                                /* auth fd to validate pvmd ident */ 
 3008         int i;
 3009         char buf[16];                                   /* for converting sockaddr */ 
 3010         char *p;
 3011         struct pvmminfo minfo;
 3012         int outtid, outctx, outtag;
 3013         int trctid, trcctx, trctag;
 3014         int need_trcinfo = 0;
 3015         int new_tracer = 0;
 3016         char tmask[ 2 * TEV_MASK_LENGTH ];
 3017         int tbuf, topt;
 3018         int mid;
 3019 #ifdef IMA_BEOLIN 
 3020         struct hostent *hostaddr;
 3021         char namebuf[128]; 
 3022 #endif 
 3023         TEV_DECLS 
 3024 #ifdef WIN32 
 3025  
 3026    /*   WSAStartup has to be called before any socket command 
 3027                 can be executed. Why ? Ask Bill 
 3028    */ 
 3029         for (ep=environ;*ep;ep++)
 3030                 pvmputenv(*ep);    
 3031    if (WSAStartup(0x0101, &WSAData) != 0)
 3032         {
 3033       fprintf(stderr,"\nWSAStartup() failed\n");
 3034       ExitProcess(1);
 3035         } 
 3036         /* setsockopt(INVALID_SOCKET,SOL_SOCKET,SO_OPENTYPE, */ 
 3037         /*      (char *)&nAlert,sizeof(int)); */ 
 3038  
 3039 #endif 
 3040 /*
 3041         pvm_setopt(PvmDebugMask, -1);
 3042 */ 
 3043         if (pvmmytid != -1)
 3044                 return 0;
 3045  
 3046         pvmmydsig = pvmgetdsig();
 3047  
 3048         TEV_EXCLUSIVE;
 3049  
 3050         authfn[0] = 0;
 3051  
 3052 #ifndef WIN32 
 3053         pvmmyupid = getpid();
 3054 #else 
 3055         pvmmyupid = _getpid();     /* .... */ 
 3056 #endif 
 3057  
 3058         /*
 3059         * get expected pid from environment in case we were started by 
 3060         * the pvmd and someone forked again 
 3061         */ 
 3062  
 3063         if (p = getenv("PVMEPID"))
 3064                 cookie = atoi(p);
 3065         else 
 3066                 cookie = 0;
 3067  
 3068         /* if ((pvm_useruid = getuid()) == -1) */ 
 3069  
 3070 #ifndef WIN32 
 3071         if ((pvm_useruid = geteuid()) == -1) {
 3072                 pvmlogerror("can't getuid()\n");
 3073                 cc = PvmSysErr;
 3074                 goto bail2;
 3075         }
 3076         pvmchkuid( pvm_useruid );
 3077 #else 
 3078         if (!username)
 3079                 username = MyGetUserName(); 
 3080 #endif 
 3081  
 3082         if (p = getenv("PVMTASKDEBUG")) {
 3083                 pvmdebmask = pvmstrtoi(p);
 3084                 if (pvmdebmask) {
 3085                         pvmlogprintf("task debug mask is 0x%x (%s)\n",
 3086                                         pvmdebmask, debug_flags(pvmdebmask));
 3087                 }
 3088         }
 3089  
 3090 #ifndef IMA_MPP 
 3091         if (cc = mksocs())              /* make socket to talk to pvmd */ 
 3092                 goto bail2;
 3093 #endif 
 3094  
 3095         /*
 3096         *       initialize received-message list 
 3097         */ 
 3098  
 3099         pvmrxlist = pmsg_new(1);
 3100         BZERO((char*)pvmrxlist, sizeof(struct pmsg));   /* Null Pointer Dereference (ID: 22107.29040) */
 3101         pvmrxlist->m_link = pvmrxlist->m_rlink = pvmrxlist;
 3102  
 3103         ttlist = TALLOC(1, struct ttpcb, "tpcb");
 3104         BZERO((char*)ttlist, sizeof(struct ttpcb));   /* Null Pointer Dereference (ID: 354.29039) */
 3105         ttlist->tt_link = ttlist->tt_rlink = ttlist;
 3106  
 3107         sbf = pvm_setsbuf(pvm_mkbuf(PvmDataFoo));
 3108         rbf = pvm_setrbuf(0);
 3109  
 3110         /*
 3111         *       create empty t-auth file that pvmd must write and we'll check later 
 3112         */ 
 3113  
 3114 #ifndef IMA_MPP 
 3115 #ifndef NOPROT 
 3116         (void)PVMTMPNAMFUN(authfn);
 3117 #ifdef IMA_OS2 
 3118         if ((authfd = open(authfn, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, 0600)) == -1) 
 3119 #else 
 3120         if ((authfd = open(authfn, O_RDONLY|O_CREAT|O_EXCL|O_TRUNC, 0600)) == -1)
 3121 #endif 
 3122         {
 3123                 pvmlogperror(authfn);
 3124                 pvmlogerror("pvmbeatask() can't creat t-auth file\n");
 3125                 cc = PvmSysErr;
 3126                 goto bail2;
 3127         }
 3128 #endif 
 3129  
 3130         /*
 3131         *       send first connect message to pvmd 
 3132         */ 
 3133  
 3134         mxfersingle = 1;
 3135         prver = TDPROTOCOL;
 3136         pvm_pkint(&prver, 1, 1);
 3137         pvm_pkstr(authfn);
 3138         if ((cc = msendrecv(TIDPVMD, TM_CONNECT, SYSCTX_TM)) <= 0)
 3139                 goto bail;
 3140         pvm_upkint(&prver, 1, 1);
 3141         if (prver != TDPROTOCOL) {
 3142                 pvmlogprintf("pvmbeatask() t-d protocol mismatch (%d/%d)\n",
 3143                         TDPROTOCOL, prver);
 3144                 cc = PvmSysErr;
 3145                 goto bail;
 3146         }
 3147         pvm_upkint(&cc, 1, 1);
 3148         if (!cc) {
 3149                 pvmlogerror("pvmbeatask() pvmd refuses connection\n");
 3150                 cc = PvmSysErr;
 3151                 goto bail;
 3152         }
 3153  
 3154         /*
 3155         *       check our t-auth file; write in pvmd d-auth file 
 3156         */ 
 3157  
 3158 #ifndef NOPROT 
 3159  
 3160 #ifdef IMA_BEOLIN 
 3161         sleep(15);  /* because of race condition over NFS--yuck! (PLS) */ 
 3162 #endif 
 3163  
 3164         if ((cc = read(authfd, (char*)&cc, 1)) == -1) {
 3165                 pvmlogperror("pvmbeatask() read authfile");
 3166                 cc = PvmSysErr;
 3167                 goto bail;
 3168         }
 3169         if (cc != 1) {
 3170                 pvmlogerror("pvmbeatask() pvmd didn't validate itself\n");
 3171                 cc = PvmSysErr;
 3172                 goto bail;
 3173         }
 3174         (void)close(authfd);
 3175         (void)unlink(authfn);   /* File System Race Condition (ID: 352.29038) */
 3176  
 3177         pvm_upkstr(authfn);
 3178         if ((authfd = open(authfn, O_WRONLY, 0)) == -1) {   /* File System Race Condition (ID: 353.29036) */
 3179                 pvmlogperror(authfn);
 3180                 pvmlogerror("pvmbeatask() failed to open d-auth file\n");
 3181                 authfn[0] = 0;
 3182                 cc = PvmSysErr;
 3183                 goto bail;
 3184         }
 3185         cc = write(authfd, authfn, 1);
 3186         (void)close(authfd);
 3187         if (cc != 1) {
 3188                 if (cc == -1)
 3189                         pvmlogperror(authfn);
 3190                 pvmlogerror("pvmbeatask() can't write d-auth file\n");
 3191                 authfn[0] = 0;
 3192                 cc = PvmSysErr;
 3193                 goto bail;
 3194         }
 3195         authfd = -1;
 3196         authfn[0] = 0;
 3197  
 3198 #endif 
 3199  
 3200         /*
 3201         *       send second connect message to pvmd 
 3202         */ 
 3203  
 3204         pvm_initsend(PvmDataFoo);
 3205         pvm_pkint(&pvmmyupid, 1, 1);
 3206         pvm_pkint(&cookie, 1, 1);
 3207         if ( pvmmytaskname != NULL )
 3208                 pvm_pkstr(pvmmytaskname);
 3209         if ((cc = msendrecv(TIDPVMD, TM_CONN2, SYSCTX_TM)) <= 0)
 3210                 goto bail;
 3211         pvm_upkint(&cc, 1, 1);
 3212         if (!cc) {
 3213                 pvmlogerror("pvmbeatask() pvmd refuses connection\n");
 3214                 cc = PvmSysErr;
 3215                 goto bail;
 3216         }
 3217 #endif /* IMA_MPP */ 
 3218  
 3219 #ifdef IMA_MPP 
 3220         pvm_mpp_beatask(&pvmmytid, &pvmmyptid, &outtid, &outctx,  
 3221                                 &outtag, &trctid, &trcctx,&trctag, &pvmudpmtu,
 3222                                 &pvmschedtid, &topvmd); 
 3223 #else 
 3224         pvm_upkint(&pvmmytid, 1, 1);
 3225         pvm_upkint(&pvmmyptid, 1, 1);
 3226  
 3227         pvm_upkint(&outtid, 1, 1);
 3228         pvm_upkint(&outctx, 1, 1);
 3229         pvm_upkint(&outtag, 1, 1);
 3230 #endif 
 3231         if (!pvmtrc.outtid) {
 3232                 pvmtrc.outtid = outtid;
 3233                 pvmtrc.outctx = outctx;
 3234                 pvmtrc.outtag = outtag;
 3235                 pvmctrc.outtid = pvmtrc.outtid;
 3236                 pvmctrc.outctx = pvmtrc.outctx;
 3237                 pvmctrc.outtag = pvmtrc.outtag;
 3238         }
 3239  
 3240 #ifndef IMA_MPP 
 3241         pvm_upkint(&trctid, 1, 1);
 3242         pvm_upkint(&trcctx, 1, 1);
 3243         pvm_upkint(&trctag, 1, 1);
 3244 #endif 
 3245         if (!pvmtrc.trctid) {
 3246                 pvmtrc.trctid = trctid;
 3247                 pvmtrc.trcctx = trcctx;
 3248                 pvmtrc.trctag = trctag;
 3249                 pvmctrc.trctid = pvmtrc.trctid;
 3250                 pvmctrc.trcctx = pvmtrc.trcctx;
 3251                 pvmctrc.trctag = pvmtrc.trctag;
 3252                 new_tracer++;
 3253         }
 3254  
 3255         if (p = getenv("PVMCTX"))
 3256                 pvmmyctx = pvmstrtoi(p);
 3257 /*  
 3258         if (pvmmyctx == 0)
 3259                 pvmmyctx = pvm_newcontext();
 3260 */ 
 3261  
 3262         /* get trace mask from envar or zero it */ 
 3263  
 3264         if ( (p = getenv("PVMTMASK")) ) {
 3265                 if ( strlen(p) + 1 == TEV_MASK_LENGTH )
 3266                         BCOPY(p, pvmtrc.tmask, TEV_MASK_LENGTH);
 3267                 else 
 3268                         TEV_MASK_INIT(pvmtrc.tmask);
 3269         } else {
 3270                 TEV_MASK_INIT(pvmtrc.tmask);
 3271                 if ( new_tracer ) need_trcinfo++;
 3272         }
 3273  
 3274         BCOPY(pvmtrc.tmask, pvmctrc.tmask, TEV_MASK_LENGTH);
 3275  
 3276         /* get trace buffering from envar */ 
 3277  
 3278         if ((p = getenv("PVMTRCBUF")))
 3279                 pvmtrc.trcbuf = atoi( p );
 3280         else {
 3281                 pvmtrc.trcbuf = 0;
 3282                 if ( new_tracer ) need_trcinfo++;
 3283         }
 3284  
 3285         pvmctrc.trcbuf = pvmtrc.trcbuf;
 3286  
 3287         /* get trace options from envar */ 
 3288  
 3289         if ((p = getenv("PVMTRCOPT")))
 3290                 pvmtrc.trcopt = atoi( p );
 3291         else {
 3292                 pvmtrc.trcopt = 0;
 3293                 if ( new_tracer ) need_trcinfo++;
 3294         }
 3295  
 3296         pvmctrc.trcopt = pvmtrc.trcopt;
 3297  
 3298 #ifndef IMA_MPP 
 3299         pvm_upkint(&pvmudpmtu, 1, 1);
 3300 #endif 
 3301         pvmfrgsiz = pvmudpmtu;
 3302  
 3303 #ifndef IMA_MPP 
 3304         pvm_upkint(&i, 1, 1);   /* XXX data signature */ 
 3305  
 3306         pvm_upkstr(buf);
 3307  
 3308 #ifdef IMA_BEOLIN 
 3309         hex_inadport(buf, &pvmourinet); /* fixed to pass proper address */ 
 3310         if (pvmdebmask & PDMROUTE)
 3311                 {
 3312                 pvmlogprintf( "mroute(): pvmourinet is %s\n", inadport_hex( &pvmourinet ) );
 3313                 }
 3314 #if 0 
 3315         if (gethostname(namebuf, sizeof(namebuf)-1) == -1) {
 3316                 pvmlogerror("pvmbeatask() can't gethostname()\n");
   ...
 3323                         hex_inadport(buf, &pvmourinet);
 3324                 } else {
 3325                         /* got addr, now save it */ 
 3326                         BCOPY( hostaddr->h_addr_list[0],
 3327                                         (char*)&pvmourinet.sin_addr,
 3328                                         sizeof(struct in_addr));
 3329                 }
 3330         }
 3331 #endif 
 3332 #else 
 3333         hex_inadport(buf, &pvmourinet);
 3334 #endif  /* IMA_BEOLIN */ 
 3335  
 3336         pvmourinet.sin_family = AF_INET;
 3337         pvmourinet.sin_port = 0;
 3338  
 3339         pvm_upkint(&pvmschedtid, 1, 1);
 3340 #endif 
 3341  
 3342         wait_init(pvmmytid, TIDLOCAL);
 3343  
 3344         BZERO(&minfo, sizeof(minfo));
 3345         minfo.src = -1;
 3346         minfo.ctx = SYSCTX_TC;
 3347         minfo.tag = TC_CONREQ;
 3348         pvm_addmhf(minfo.src, minfo.tag, minfo.ctx, pvm_tc_conreq);
 3349         minfo.tag = TC_CONACK;
 3350         pvm_addmhf(minfo.src, minfo.tag, minfo.ctx, pvm_tc_conack);
 3351         minfo.tag = TC_TASKEXIT;
 3352         pvm_addmhf(minfo.src, minfo.tag, minfo.ctx, pvm_tc_taskexit);
 3353         minfo.tag = TC_NOOP;
 3354         pvm_addmhf(minfo.src, minfo.tag, minfo.ctx, pvm_tc_noop);
 3355         minfo.tag = TC_SETTRACE;
 3356         pvm_addmhf(minfo.src, minfo.tag, minfo.ctx, pvm_tc_settrace);
 3357         minfo.tag = TC_SETTRCBUF;
 3358         pvm_addmhf(minfo.src, minfo.tag, minfo.ctx, pvm_tc_settrcbuf);
 3359         minfo.tag = TC_SETTRCOPT;
 3360         pvm_addmhf(minfo.src, minfo.tag, minfo.ctx, pvm_tc_settrcopt);
 3361         minfo.tag = TC_SETTMASK;
 3362         pvm_addmhf(minfo.src, minfo.tag, minfo.ctx, pvm_tc_settmask);
 3363         minfo.tag = TC_SIBLINGS;
 3364         pvm_addmhf(minfo.src, minfo.tag, minfo.ctx, pvm_tc_siblings);
 3365  
 3366         pvm_freebuf(pvm_setrbuf(rbf));
 3367         pvm_freebuf(pvm_setsbuf(sbf));
 3368         mxfersingle = 0;
 3369  
 3370         if ( need_trcinfo )
 3371         {
 3372                 rbf = pvm_setrbuf( 0 );
 3373  
 3374                 if ( pvm_recvinfo( PVMTRACERCLASS, 0, PvmMboxDefault ) > 0 )
 3375                 {
 3376                         pvm_upkint(&trctid, 1, 1);
 3377  
 3378                         pvm_upkint(&trcctx, 1, 1);
 3379                         pvm_upkint(&trctag, 1, 1);
 3380  
 3381                         pvm_upkint(&outctx, 1, 1);  /* unused here */ 
 3382                         pvm_upkint(&outtag, 1, 1);  /* unused here */ 
 3383  
 3384                         pvm_upkstr(tmask);
 3385  
 3386                         pvm_upkint(&tbuf, 1, 1);
 3387                         pvm_upkint(&topt, 1, 1);
 3388  
 3389                         if ( pvmtrc.trctid == trctid && pvmtrc.trcctx == trcctx 
 3390                                         && pvmtrc.trctag == trctag )
 3391                         {
tmask is uninitialized3392                                 if ( strlen(tmask) + 1 == TEV_MASK_LENGTH ) {     /* Uninitialized Variable */
Preconditions
&$unknown_1301011 != 0
&$unknown_1301013 = &$unknown_1301014 + 92
&$unknown_1301023 >= 1
&$unknown_1301039 >= 1
&$unknown_1301041 != 0
&$unknown_1301089 >= 1
&$unknown_1301091 != 0
handles >= 0
((char*)&$heap_340768)[1] <= 120
((char*)&$heap_340768)[1] >= 48
myfmt != -1
nhandles >= 0
pvmmytid = -1
pvmrbuf = 0
pvmtoplvl = 0
pvmtrc.trctid = 0
pvmtrc.outtid = 0
$input_12 >= 1
$input_236052 = 1
$input_236060 = 1
$input_236068 >= 1
$input_236076 = 48
$input_444 = 48
$input_852 = 0
waitlist != 0
Postconditions
((char*)$unknown_1301014)[4]' = &$unknown_1301013
((char*)&$unknown_1301013)[4]' = ((char*)&$unknown_1301014)[4]
((char*)&$unknown_1301014)[20]' = 1
((char*)&$unknown_1301014)[32]' = 0
((char*)&$unknown_1301014)[44]' = 0
((char*)&$unknown_1301014)[52]' = 0
((char*)&$unknown_1301014)[60]' = 0
((char*)&$unknown_1301014)[64]' = 0
authfd' = -1
authfn[0]' = 0
strlen(&authfn[0])' = 0
authfn[0]' is accessed by path name
buf[0]' = 0
strlen(&buf[0])' = 0
cc' = &$unknown_1301041
strlen(&cc)' = $input_852
ep' = 0
$heap_340768' = $input_444
bytes_after(&$heap_340768)' = $input_12 + 1
$heap_340768' is allocated by malloc
$heap_340768' is a non-heap object
bytes_before(&$heap_340768)' = 0
strlen(&$heap_340768)' = $input_12
bytes_after(&$heap_340769)' = 64
$heap_340769' is allocated by malloc
$heap_340769' is allocated
bytes_before(&$heap_340769)' = 0
$heap_340771' is allocated by open
$heap_340771' is freed
$heap_340772' is allocated by open
$heap_340773' = $input_236076
bytes_after(&$heap_340773)' = $input_236068 + 1
$heap_340773' is allocated by malloc
$heap_340773' is a non-heap object
bytes_before(&$heap_340773)' = 0
strlen(&$heap_340773)' = $input_236068
minfo.len' = 0
minfo.src' = -1
minfo.ctx' = 524287
minfo.tag' = -2147287028
mxfersingle' = 0
need_trcinfo' = 3
new_tracer' = 1
p' = 0
prver' = 1318
pvm_useruid' != -1
pvmampushed' = 0
pvmamtraced' = pvmtoplvl
pvmctrc.trcbuf' = 0
pvmctrc.trcopt' = 0
pvmctrc.tmask[0]' = pvmtrc.tmask[0]
pvmctrc.outtid' = outtid'
pvmdebmask' = &$unknown_1301011
pvmmydsig' = myfmt
pvmourinet.sin_family' = 2
pvmourinet.sin_port' = 0
pvmrbuf' = &$unknown_1301091
pvmrxlist' = &$unknown_1301014
pvmtrc.trctid' = pvmctrc.trctid'
pvmtrc.outctx' = pvmctrc.outctx'
pvmtrc.outtag' = pvmctrc.outtag'
pvmtrc.trcbuf' = 0
pvmtrc.trcopt' = 0
strlen(&pvmtrc.tmask[0])' != 0
pvmtrc.trcctx' = pvmctrc.trcctx'
pvmtrc.tmask[35]' = 0
pvmtrc.trctag' = pvmctrc.trctag'
pvmtrc.outtid' = outtid'
pvmudpmtu' = pvmfrgsiz'
rbf' = 0
sbf' = &$unknown_1301078
tev_init_mask_i' = -1
trcctx' = pvmctrc.trcctx'
trctag' = pvmctrc.trctag'
trctid' = pvmctrc.trctid'
ttlist' = &$heap_340769




Change Warning 22106.29033 : Uninitialized Variable

Priority:
State:
Finding:
Owner:
Note: