Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Null Pointer Dereference  at lpvm.c:3720

Categories: LANG.MEM.NPD CWE:476
Warning ID: 2836.2897
Procedure: pvm_start_pvmd
Trace: View
Modified: Wed Sep 2 12:49:34 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
 3526 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;
true3720         pvmputenv(STRALLOC(buf));     /* Null Pointer Dereference */
Preconditions
$param_1 >= 1
&$unknown_2495950 >= 0
&$unknown_2495952 = 0
pp = 0
pvmmytid != -1
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
*stderr' is allocated by fopen
bytes_before(stderr)' = 0
$unknown_2495949' is freed
$unknown_2495949' is closed
$unknown_2495950' is freed
$unknown_2495950' is closed
argc' = $param_1
argv' = $param_2
av' = &$heap_201505
buf[0]' = 80
strlen(&buf[0])' = $input_500 + 7
buf[0]' is checked by path name
buf[8]' = $input_508
errno' != 0
ff' = &$heap_201506
fn' = &$heap_201504
bytes_after(&$heap_201503)' = $input_12 + 1
$heap_201503' is allocated by malloc
$heap_201503' is a non-heap object
bytes_before(&$heap_201503)' = 0
strlen(&$heap_201503)' = $input_12
bytes_after(&$heap_201504)' = $input_12 + 10
$heap_201504' is allocated by malloc
$heap_201504' is allocated
bytes_before(&$heap_201504)' = 0
$heap_201505' = &$heap_201504
bytes_after(&$heap_201505)' = 8 * $param_1 + 16
$heap_201505' is allocated by malloc
$heap_201505' is freed
bytes_before(&$heap_201505)' = 0
bytes_after(&$heap_201506)' = 1028
$heap_201506' is allocated by fopen
$heap_201506' is closed
bytes_before(&$heap_201506)' = 0
n' = $input_500 + 8
newline' = 1
pfd[0]' = &$unknown_2495950
pfd[1]' = &$unknown_2495949
pp' = &$heap_201504
pvm_useruid' != -1
pvmampushed' = 0
pvmamtraced' = pvmtoplvl
pvmtoplvl' = 0
pvmtrccodef' = &pvmtrccodef_nop.enc_byte
rd' = &$heap_201503
sfn' = &buf[0]
td' = &#string21[0]




Change Warning 2836.2897 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: