Try to figure out what the problem is with the following C++ code. I've seen this bug in the wild, so I thought I'd share it with everyone.

    int number;
    char* buffer = new char[8]();
    _itoa(number,buffer,10);

The problem is that the character buffer is only 8 characters long. This means the buffer can store 7 digits plus the terminating null. A 32 bit int could potentially have many more than 7 digits, so the call to _itoa() could potentially write past the end of the buffer.

 
Tuesday, December 04, 2007 6:58:18 AM (Pacific Standard Time, UTC-08:00)
very nice
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: )  

Enter the code shown (prevents robots):

Live Comment Preview