Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Integer Overflow of Allocation Size  at pvmfperror.c:36

Categories: ALLOC.IOAS BSI:MALLOC-OVERFLOW CWE:680
Warning ID: 540.29331
Procedure: pvmfperror_
Trace: view
Modified: Thu Nov 26 11:37:58 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/libfpvm/LINUX/pvmfperror.c
   Enter pvmfperror_
 19 pvmfperror_ (p_ptr, info, p_len) 
 20 char * p_ptr; int p_len;
 21         int *info;
 22 {
 23         static char *buf = 0;
 24         static int buflen = 0;
 25  
 26         /*
 27          * Have to have a NUL at the end of the string, and 
 28          * the only way to do this portably is to copy the whole string 
 29          * into a malloc'ed buffer.  We keep the buffer around for 
 30          * future use rather than free'ing it each time we're done.
 31          */ 
 32         if (!buf)
 33                 buf = malloc(buflen = p_len + 1);
 34         else 
 35                 if (p_len + 1 > buflen) {
true36                         buflen = MAX(p_len + 1, buflen * 2);     /* Integer Overflow of Allocation Size */
 37                         /* don't use realloc; it might cause old data to be copied */ 
 38                         free(buf);
buflen overflowed39                         buf = malloc(buflen);
Preconditions
buf != 0
buflen <= p_len
buflen >= ( p_len + 1 ) / 2
$input_12 = 0
Postconditions
*buf' is freed
buflen' = 2 * buflen




Change Warning 540.29331 : Integer Overflow of Allocation Size

Priority:
State:
Finding:
Owner:
Note: