Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Uninitialized Variable  at lpvm.c:3734

Categories: LANG.MEM.UVAR CWE:457
Warning ID: 2835.2896
Procedure: pvm_start_pvmd
Trace: View
Modified: Wed Sep 2 12:49:33 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 pvm_start_pvmd
true3526 pvm_start_pvmd(argc, argv, block) 
 3527         int argc;               /* number of args to pass to pvmd (>= 0) */ 
 3528         char **argv;    /* args for pvmd or null */ 
 3529         int block;              /* if true, don't return until add hosts are started */ 
 3530 {
 3531         char *sfn;
 3532         struct stat sb;
 3533         int cc;
 3534         char *fn;                       /* file to exec */ 
 3535         char **av;
 3536         int pfd[2];
   ...
 3541 #ifdef WIN32 
 3542         char *pathending = "\\lib\\win32\\pvmd3.exe";
 3543         SECURITY_ATTRIBUTES saPipe;
 3544         PROCESS_INFORMATION pi;
 3545         STARTUPINFO si;  /* for CreateProcess call */ 
 3546         HANDLE pvmdid;
 3547         int i = 0;
 3548         char cmd[256]; 
 3549 #endif 
 3550  
 3551         TEV_DECLS;
 3552  
 3553         if (TEV_EXCLUSIVE) {
 3554                 if (pvmmytid != -1 
 3555                                 && TEV_DO_TRACE(TEV_START_PVMD,TEV_EVENT_ENTRY)) {
 3556                         TEV_PACK_INT( TEV_DID_BF, TEV_DATA_SCALAR, &block, 1, 1 );
 3557                         TEV_PACK_STRING( TEV_DID_AS, TEV_DATA_ARRAY,
 3558                                 argv, argc, 1 );
 3559                         TEV_FIN;
 3560                 }
 3561         }
 3562  
 3563         if (argc < 0 || !argv)
 3564                 argc = 0;
 3565  
 3566 #ifndef WIN32 
 3567         if ((pvm_useruid = getuid()) == -1) {
 3568                 pvmlogerror("can't getuid()\n");
 3569                 cc = PvmSysErr;
 3570                 goto bail;
 3571         }
 3572         pvmchkuid( pvm_useruid );
 3573 #else 
 3574         if (!username)  
 3575                 username = MyGetUserName(); 
 3576 #endif 
 3577  
 3578         if (!(sfn = pvmdsockfile())) {
 3579                 pvmlogerror("pvm_start_pvmd() pvmdsockfile() failed\n");
 3580                 cc = PvmSysErr;
 3581                 goto bail;
 3582         }
 3583  
 3584         if (stat(sfn, &sb) != -1) {
 3585                 cc = PvmDupHost;
 3586                 goto bail;
 3587         }
 3588  
 3589 #ifdef WIN32  
 3590  
 3591         cc = PvmSysErr;
 3592  
 3593         fn = malloc(128 * sizeof(char));
 3594          
   ...
 3650         PVM_FREE(av);
 3651  
 3652         while (stat(sfn, &sb) == -1)
 3653                 Sleep(5000);            /* what a hack */ 
 3654  
 3655 #else 
 3656  
 3657 #ifdef  IMA_TITN 
 3658         if (socketpair(AF_UNIX, SOCK_STREAM, 0, pfd) == -1) 
 3659 #else 
 3660         if (pipe(pfd) == -1)
 3661 #endif 
 3662         {
 3663                 cc = PvmSysErr;
 3664                 goto bail;
 3665         }
 3666  
 3667         fn = pvmgetpvmd();
 3668  
 3669         av = TALLOC(argc + 2, char *, "argv");
 3670         if (argc > 0)
 3671                 BCOPY((char *)&argv[0], (char *)&av[1], argc * sizeof(char*));   /* Null Pointer Dereference (ID: 2837.2898) */
 3672         av[0] = fn;   /* Null Pointer Dereference (ID: 2838.2899) */
 3673         av[argc + 1] = 0;
 3674  
 3675         if (!fork()) {
 3676                 (void)close(pfd[0]);
 3677         /* fork again so the pvmd is not the child - won't have to wait() for it */ 
 3678                 if (!fork()) {
 3679                         if (pfd[1] != 1)
 3680                                 dup2(pfd[1], 1);
 3681                         for (n = getdtablesize(); n-- > 0; )
 3682                                 if (n != 1)
 3683                                         (void)close(n);
 3684                         (void)open("/dev/null", O_RDONLY, 0);   /* should be 0 */ 
 3685                         (void)open("/dev/null", O_WRONLY, 0);   /* should be 2 */ 
 3686                         (void)signal(SIGINT, SIG_IGN);
 3687                         (void)signal(SIGQUIT, SIG_IGN);
 3688 #ifndef IMA_OS2 
 3689                         (void)signal(SIGTSTP, SIG_IGN);
 3690 #endif 
 3691                         execvp(av[0], av);
 3692                 }
 3693                 _exit(0);
 3694         }
 3695         (void)close(pfd[1]);
 3696         (void)wait(0);
 3697         PVM_FREE(av);
 3698  
 3699         if (!(ff = fdopen(pfd[0], "r"))) {
 3700                 cc = PvmSysErr;
 3701                 (void)close(pfd[0]);
 3702                 goto bail;
 3703         }
 3704  
 3705         strcpy(buf, "PVMSOCK=");
 3706         n = strlen(buf);
 3707         if (!fgets(buf + n, sizeof(buf) - n - 1, ff)) {
 3708                 cc = PvmCantStart;
 3709                 fclose(ff);
 3710                 goto bail;
 3711         }
 3712         fclose(ff);
 3713         if (strlen(buf + n) < 2) {
 3714                 cc = PvmCantStart;
 3715                 goto bail;
 3716         }
 3717         n = strlen(buf);
 3718         if (buf[n - 1] == '\n')
 3719                 buf[n - 1] = 0;
 3720         pvmputenv(STRALLOC(buf));   /* Null Pointer Dereference (ID: 2836.2897) */
 3721  
 3722         /* fprintf(stderr, "pvm_start_pvmd: %s\n", buf); */ 
 3723  
 3724 #endif 
 3725  
 3726         if (cc = BEATASK)
 3727                 goto bail;
 3728  
 3729         if (block) {
 3730                 struct pvmhostinfo *hip;
 3731                 int t = 1;
 3732  
 3733                 pvm_config((int*)0, (int*)0, &hip);
hip is uninitialized3734                 while ((cc = pvm_addhosts(&hip[0].hi_name, 1, (int*)0)) == PvmAlready) {     /* Uninitialized Variable */
 3735                         pvmsleep(t);
 3736                         if (t < 8)
 3737                                 t *= 2;
Preconditions
$param_1 = 0
$param_2 != 0
&$unknown_2494607 >= 0
&$unknown_2494609 != 0
&$unknown_2494616 = 1
hlist = 0
numpmsgs = 0
pp = 0
pvmautoerr = 0
pvmmytid != -1
pvmrbuf = 0
pvmschedtid != 0
pvmtoplvl != 0
pvmtrc.trctid != pvmmytid
pvmtrc.trctid >= 1
pvmtrc.trcopt != 1
pvmtrc.trcopt != 2
pvmtrc.trcopt != 3
rd = 0
$input_12 >= 0
$input_500 <= 118
$input_500 >= 2
td = 0
Postconditions
pvmsbuf->m_ctx' = 0
$unknown_2494606' is freed
$unknown_2494606' is closed
$unknown_2494607' is freed
$unknown_2494607' is closed
argc' = $param_1
argv' = $param_2
av' = &$heap_200989
block' = &$unknown_2494609
buf[0]' = 80
strlen(&buf[0])' = $input_500 + 7
buf[0]' is checked by path name
buf[8]' = $input_508
cc' = -30
ff' = &$heap_200990
fn' = &$heap_200988
bytes_after(&$heap_200987)' = $input_12 + 1
$heap_200987' is allocated by malloc
$heap_200987' is a non-heap object
bytes_before(&$heap_200987)' = 0
strlen(&$heap_200987)' = $input_12
bytes_after(&$heap_200988)' = $input_12 + 10
$heap_200988' is allocated by malloc
$heap_200988' is allocated
bytes_before(&$heap_200988)' = 0
$heap_200989' = &$heap_200988
bytes_after(&$heap_200989)' = 8 * $param_1 + 16
$heap_200989' is allocated by malloc
$heap_200989' is freed
bytes_before(&$heap_200989)' = 0
((char*)&$heap_200989)[8]' = 0
$heap_200990' = &$unknown_2494607
bytes_after(&$heap_200990)' = 1028
$heap_200990' is allocated by fopen
$heap_200990' is freed
$heap_200990' is closed
bytes_before(&$heap_200990)' = 0
$heap_200991' = 80
bytes_after(&$heap_200991)' = $input_500 + 8
$heap_200991' is allocated by malloc
$heap_200991' is allocated
bytes_before(&$heap_200991)' = 0
strlen(&$heap_200991)' = $input_500 + 7
n' = $input_500 + 8
pfd[0]' = &$unknown_2494607
pfd[1]' = &$unknown_2494606
pp' = &$heap_200988
pvmampushed' = 0
pvmamtraced' = pvmtoplvl
pvmtoplvl' = 0
rd' = &$heap_200987
sfn' = &buf[0]




Change Warning 2835.2896 : Uninitialized Variable

Priority:
State:
Finding:
Owner:
Note: