Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Null Pointer Dereference  at lpvm.c:3691

Categories: LANG.MEM.NPD CWE:476
Warning ID: 22143.29133
Procedure: pvm_start_pvmd
Trace: view
Modified: Thu Nov 26 11:34:47 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 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  
true3667         fn = pvmgetpvmd();
 3668  
 3669         av = TALLOC(argc + 2, char *, "argv");   /* Integer Overflow of Allocation Size (ID: 414.29137) */
 3670         if (argc > 0)
 3671                 BCOPY((char *)&argv[0], (char *)&av[1], argc * sizeof(char*));   /* Null Pointer Dereference (ID: 22145.29136) */
fn <= 40953672         av[0] = fn;   /* Null Pointer Dereference (ID: 413.29135) */
 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);   /* Leak (ID: 22141.29131) */
 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 */   /* File System Race Condition (ID: 22144.29134) */
 3686                         (void)signal(SIGINT, SIG_IGN);
 3687                         (void)signal(SIGQUIT, SIG_IGN);
 3688 #ifndef IMA_OS2 
 3689                         (void)signal(SIGTSTP, SIG_IGN);
 3690 #endif 
*av <= 40953691                         execvp(av[0], av);     /* Null Pointer Dereference */
Preconditions
argc >= 0
argv = 0
&$unknown_11050067 >= 1
pp = 0
pvmmytid = -1
pvmtoplvl != 0
$input_12 >= 0
td = 0
Postconditions
$unknown_11050066' is freed
argc' = 0
av' = &$heap_385826
strlen(&buf[0])' = $input_12 + 17
buf[0]' is accessed by path name
errno' != 0
fn' = 0
$heap_385825' = $input_444
bytes_after(&$heap_385825)' = $input_12 + 1
$heap_385825' is allocated by malloc
$heap_385825' is a non-heap object
bytes_before(&$heap_385825)' = 0
strlen(&$heap_385825)' = $input_12
$heap_385826' = 0
bytes_after(&$heap_385826)' = 8
$heap_385826' is allocated by malloc
$heap_385826' is allocated
bytes_before(&$heap_385826)' = 0
((char*)&$heap_385826)[4]' = 0
$heap_385827' is allocated by open
$heap_385827' is allocated
n' = -1
pfd[0]' = &$unknown_11050066
pfd[1]' != 1
pp' = 0
pvm_useruid' != -1
pvmampushed' = 0
pvmamtraced' = pvmtoplvl
pvmtoplvl' = 0
sfn' = &buf[0]
td' = &$heap_385825




Change Warning 22143.29133 : Null Pointer Dereference

Priority:
State:
Finding:
Owner:
Note: