Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : File System Race Condition  at lpvm.c:3430

Categories: IO.RACE CWE:367
Warning ID: 352.29037
Similar Warnings: 352.29038
Procedure: pvmbeatask
Trace: view
Modified: Thu Nov 26 11:30:00 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
 2999 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 
true3120         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 
   ...
 3408                         pvm_setrbuf(rbf);
 3409         }
 3410  
 3411         tev_init();
 3412  
 3413         if (TEV_AMEXCL) {
 3414                 TEV_ENDEXCL;
 3415         }
 3416         return 0;
 3417  
 3418 bail: 
 3419         if (pvm_getrbuf() > 0)
 3420                 pvm_freebuf(pvm_getrbuf());
 3421         if (pvm_getsbuf() > 0)
 3422                 pvm_freebuf(pvm_getsbuf());
 3423         pvm_setrbuf(rbf);
 3424         pvm_setsbuf(sbf);
 3425  
 3426 #ifndef IMA_MPP 
 3427         if (authfd != -1)
 3428                 (void)close(authfd);   /* Double Close (ID: 351.29035) */
 3429         if (authfn[0])
authfn[0] is accessed by path name3430                 (void)unlink(authfn);     /* File System Race Condition */
Preconditions
&$unknown_1372125 >= 1
&$unknown_1372136 != 0
((char*)&$unknown_1372129)[24] >= 1
myfmt = -1
pvmmytid = -1
pvmrbuf = 0
pvmtoplvl != 0
$input_12 >= 0
$input_292796 >= 1
$input_292804 = 48
$input_292812 <= 97
$input_292812 >= 0
Postconditions
((char*)$unknown_1372110)[4]' = ((char*)&$unknown_1372110)[4]
((char*)$unknown_1372110)[4]' = $unknown_1372110
*stderr' is allocated by fopen
bytes_before(stderr)' = 0
authfd' = &$heap_347668 - 4096
authfn[0]' = &$unknown_1372136
strlen(&authfn[0])' = $input_292812 + 30
authfn[0]' is accessed by path name
cc' = -14
cookie' = $input_292788
ep' = 0
errno' != 0
$heap_347664' = $input_444
bytes_after(&$heap_347664)' = $input_12 + 1
$heap_347664' is allocated by malloc
$heap_347664' is a non-heap object
bytes_before(&$heap_347664)' = 0
strlen(&$heap_347664)' = $input_12
$heap_347665' = $input_292804
bytes_after(&$heap_347665)' = $input_292796 + 1
$heap_347665' is allocated by malloc
$heap_347665' is a non-heap object
bytes_before(&$heap_347665)' = 0
strlen(&$heap_347665)' = $input_292796
$heap_347666' = &$heap_347666
bytes_after(&$heap_347666)' = 64
$heap_347666' is allocated by malloc
$heap_347666' is allocated
bytes_before(&$heap_347666)' = 0
((char*)&$heap_347666)[4]' = &$heap_347666
$heap_347668' is allocated by open
mxfersingle' = 1
need_trcinfo' = 0
new_tracer' = 0
nextwaitid' = nextwaitid + 1
p' = &$heap_347665
prver' != 1318
pvm_useruid' != -1
pvmampushed' = 0
pvmamtraced' = pvmtoplvl
pvmdebmask' = 0
pvmmidhsiz' >= 2
pvmmidhsiz' >= ((char*)&$unknown_1372129)[24] + 1
pvmrxlist' = &$unknown_1372110
pvmtoplvl' = 0
rbf' = 0
sbf' = &$unknown_1372135
ttlist' = &$heap_347666




Change Warning 352.29037 : File System Race Condition

Because they are very similar, this warning shares annotations with warning 352.29038.

Priority:
State:
Finding:
Owner:
Note: