Menu

#25 Buffer overrun: accessing 'buffer', the writable size is '32

0.5.0
closed-accepted
Reader (16)
7
2011-05-01
2010-12-18
No

Buffer overrun: accessing 'buffer', the writable size is '32' bytes, but '33' bytes might be written.
This occurs when int(token.end_ - token.start_) generates 32.
There should be "Char buffer[bufferSize+1];" instead.

double value = 0;
const int bufferSize = 32;
int count;
int length = int(token.end_ - token.start_);
if ( length <= bufferSize )
{
Char buffer[bufferSize];
memcpy( buffer, token.start_, length );
buffer[length] = 0;
count = sscanf( buffer, "%lf", &value );
}

Discussion

  • Sergey Kolomenkin

    • priority: 5 --> 7
    • assigned_to: nobody --> blep
     
  • Baptiste Lepilleur

    Fixed in trunk.

     
  • Baptiste Lepilleur

    • status: open --> open-accepted
     
  • Baptiste Lepilleur

    • status: open-accepted --> closed-accepted
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.