Text  |   XML   |   Visible Warnings:

Pvm : Pvm analysis 1 : Buffer Underrun  at pvmfstartpvmd.c:90

Categories: LANG.MEM.BU CWE:124 CWE:127
Warning ID: 2947.3030
Procedure: pvmfstartpvmd_
Trace: View
Modified: Wed Sep 2 12:54:25 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/libfpvm/LINUX64/pvmfstartpvmd.c
   Enter pvmfstartpvmd_
 30 pvmfstartpvmd_ (args_ptr, block, info, args_len) 
 31 char * args_ptr; int args_len;
 32 int *block;
 33 int *info;
 34 {
 35     char *nargs;                        /* args (null terminated) */ 
true36     int ac = 0;                         /* # of agruments initialize to 0 */ 
 37     char **av;                          /* argument vector */ 
 38     register char *ch;                  /* temp char pointer */ 
 39     register char *beg;                 /* pointer to begining of word */ 
 40     register char *end;                 /* pointer to end of word */ 
 41     register int len;                   /* length of word */ 
 42     register int i;                     /* loop index */ 
 43  
 44 #if ( DEBUG ) 
 45     /* printout incoming nargs */ 
 46     printf( "%d \"%s\"\n", args_len, args_ptr ); 
 47 #endif 
 48     /* Some Fortran compilers allow for strings of zero length */ 
 49     if ( args_len == 0 ) {      /* null args */ 
 50         av = (char **)0;                /* make av a null pointer */ 
 51         goto pvmd;
 52     } else {                            /* something in args */ 
 53         if ( ( nargs = TALLOC( args_len + 1, char, "nargs" ) ) 
 54             == NULL ) {
 55             pvmlogerror("pvmfstartpvmd() can't get memory\n");
 56             goto bail;
 57         }
 58         /* copy args (ftocptr() could have been used for that) */ 
 59         strncpy( nargs, args_ptr, args_len );
 60         nargs[args_len] = '\0'; /* terminate with null */   /* Buffer Underrun (ID: 2948.3031) */
 61     }
 62     ch = nargs;                         /* pointer at the begining of nargs */ 
 63     /* assume a max of 32 args (8 should be OK from pvmd3(3PVM)) */ 
 64     if ( ( av = TALLOC( 32, char *, "av" ) ) == NULL ) {   /* Leak (ID: 2946.3029) */
 65         pvmlogerror("pvmfstartpvmd() can't get memory\n");
 66         PVM_FREE( nargs );              /* avoid memory leeks */ 
 67         goto bail;
 68     }
 69     /* at this point nargs contain at least 1 char */ 
 70     for ( ; ; ) {
 71         /* move forward until no space nor tab */ 
 72         for( ; *ch == ' ' || *ch == '\t'; ch++ );
 73         beg = ch;                       /* that's the begining of a word */ 
 74         /* move forward until space, tab or null */ 
 75         for( ; *ch != ' ' && *ch != '\t' && *ch != '\0'; ch++ );
 76         end = ch;                       /* that's the end of a word */ 
 77         len = end - beg;                /* length of the word */ 
 78         /* if nothing else then space, tab or null has been found */ 
 79         /* then end of nargs is reached (exit point of loop) */ 
 80         if ( len == 0 ) break;
 81         /* allocate memory for word in agument vector */ 
 82         if ( ( av[ac] = TALLOC( len + 1, char, "av[ac]" ) ) == NULL ) {
 83             pvmlogerror("pvmfstartpvmd() can't get memory\n");
 84             PVM_FREE( nargs );          /* avoid memory leeks */ 
 85             for ( i = 0; i < ac; i++ )
 86                 PVM_FREE( av[i] );
 87             goto bail;
 88         }
 89         strncpy( av[ac], beg, len );    /* copy word to arg vector */ 
 90         *( av[ac] + len ) = '\0';       /* null terminate word */     /* Buffer Underrun */
Preconditions
$param_4 = -1
&$unknown_3675438 >= &$heap_253617 + 1
&$unknown_3675439 = -1
$unknown_3675438 != 0
$unknown_3675438 != 32
$unknown_3675438 != 9
strlen(&$unknown_3675438) = 1
((char*)&$unknown_3675438)[1] = 0
$heap_253617 = 32
strlen(&$heap_253617) > 1
((char*)&$heap_253617)[1] != 0
((char*)&$heap_253617)[1] != 32
((char*)&$heap_253617)[1] != 9
Postconditions
ac' = 0
args_len' = $param_4
args_ptr' = $param_1
av' = &$heap_253618
beg' = &$heap_253617 + 1
block' = $param_2
ch' = &$unknown_3675438 + 1
end' = &$unknown_3675438 + 1
bytes_after(&$heap_253617)' = $param_4 + 1
$heap_253617' is allocated by malloc
$heap_253617' is allocated
bytes_before(&$heap_253617)' = 0
((char*)&$heap_253617)[-1]' = 0
$heap_253618' = &$heap_253619
bytes_after(&$heap_253618)' = 256
$heap_253618' is allocated by malloc
$heap_253618' is allocated
bytes_before(&$heap_253618)' = 0
bytes_after(&$heap_253619)' = &$unknown_3675439 + 1
$heap_253619' is allocated by malloc
$heap_253619' is allocated
bytes_before(&$heap_253619)' = 0
info' = $param_3
len' = &$unknown_3675439
nargs' = &$heap_253617




Change Warning 2947.3030 : Buffer Underrun

Priority:
State:
Finding:
Owner:
Note: