Text  |   XML   |   Visible Warnings:

pvm3.4.6 : pvm3.4.6 analysis 2 : Integer Overflow of Allocation Size  at pvmcruft.c:514

Categories: ALLOC.IOAS BSI:MALLOC-OVERFLOW CWE:680
Warning ID: 113.28733
Procedure: pvmputenv
Trace: view
Modified: Thu Nov 26 11:27:39 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/pvmcruft.c
   Enter pvmputenv
 475 pvmputenv(s) 
 476         char *s;        /* string of form "NAME=Value" */ 
 477 {
 478         char *p;                                        /* gp */ 
 479         int l;                                          /* length of env var name or env */ 
 480         static char **myen = 0;         /* last environ that i created */ 
 481         char **newen;                           /* new env if extending */ 
 482         char **ep, **ep2;                       /* gp */ 
 483  
 484         /* sanity check the string and locate the '=' */ 
 485  
 486         if (!s)
 487                 return -1;
 488         for (p = s; *p && *p != '='; p++);
 489         if (p == s || !*p)
 490                 return -1;
 491         l = p - s + 1;  /* must include '=' */ 
 492  
 493         /* search current environ for name */ 
 494  
 495         for (ep = environ; *ep; ep++)
 496                 if (!strncmp(*ep, s, l))
 497                         break;
 498  
 499         if (*ep) {      /* already there, replace it */ 
 500                 *ep = s;
 501  
 502         } else {        /* not there, must extend environ */ 
 503  
 504         /* length needed is? */ 
 505  
 506                 for (l = 2, ep = environ; *ep; l++, ep++);
 507  
 508                 if (environ == myen) {  /* mine, reallocate */ 
 509                         if (!(newen = (char**)realloc((char *)environ,
 510                                         (unsigned)(l * sizeof(char*)))))
 511                                 return -1;
 512  
 513                 } else {        /* not mine, alloc new and copy */ 
true514                         if (!(newen = (char**)malloc((unsigned)(l * sizeof(char*)))))     /* Integer Overflow of Allocation Size */
Preconditions
&$unknown_375352 >= s
&$unknown_375355 >= environ
*s != 0
*s != 61
strlen(s) != 0
$unknown_375352 != 0
$unknown_375352 != 61
strlen(&$unknown_375352) != 0
strlen(&$unknown_375352) != 1
((char*)&$unknown_375352)[1] = 61
$unknown_375355 != 0
((char*)&$unknown_375355)[4] != 0
((char*)&$unknown_375355)[8] = 0
myen != environ
$input_12 = 0
Postconditions
ep' = &$unknown_375355 + 8
p' = &$unknown_375352 + 1




Change Warning 113.28733 : Integer Overflow of Allocation Size

Priority:
State:
Finding:
Owner:
Note: