Text   |  XML   |  ReML   |   Visible Warnings:

Integer Overflow of Allocation Size  at text2pcap-scanner.c:1498

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

yyensure_buffer_stack

(/home/sate/Testcases/c/cve/wireshark-1.2.0/text2pcap-scanner.c)expand/collapse
Show more  
 1466  static void yyensure_buffer_stack (void)
 1467  {
 1468          int num_to_alloc;
 1469       
 1470          if (!(yy_buffer_stack)) {
 1471   
 1472                  /* First allocation is just for 2 elements, since we don't know if this 
 1473                   * scanner will even need a stack. We use 2 instead of 1 to avoid an 
 1474                   * immediate realloc on the next call.
 1475           */
 1476                  num_to_alloc = 1;
 1477                  (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
 1478                                                                  (num_to_alloc * sizeof(struct yy_buffer_state*)
 1479                                                                  );
 1480                  if ( ! (yy_buffer_stack) )
 1481                          YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
 1482                                                                     
 1483                  memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
 1484                                   
 1485                  (yy_buffer_stack_max) = num_to_alloc;
 1486                  (yy_buffer_stack_top) = 0;
 1487                  return;
 1488          }
 1489   
 1490          if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
 1491   
 1492                  /* Increase the buffer to prepare for a possible push. */
 1493                  int grow_size = 8 /* arbitrary grow size */;
 1494   
 1495                  num_to_alloc = (yy_buffer_stack_max) + grow_size;
 1496                  (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
 1497                                                                  ((yy_buffer_stack),
 1498                                                                  num_to_alloc * sizeof(struct yy_buffer_state*)
 1499[+]                                                                 );
expand/collapse

yyrealloc

(/home/sate/Testcases/c/cve/wireshark-1.2.0/text2pcap-scanner.c)expand/collapse
Show more  
 1781  void *yyrealloc  (void * ptr, yy_size_t  size )
 1782  {
 1783          /* The cast to (char *) in the following accommodates both 
 1784           * implementations that use char* generic pointers, and those
 1785           * that use void* generic pointers.  It works with the latter
 1786           * because both ANSI C and C++ allow castless assignment from
 1787           * any pointer type to void*, and deal with argument conversions 
 1788           * as though doing an assignment.
 1789           */
 1790          return (void *) realloc( (char *) ptr, size );
Show more  
Show more  




Change Warning 4908.30112 : Integer Overflow of Allocation Size

Priority:
State:
Finding:
Owner:
Note: