21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The second problem area occurs when using C-style strings with the C++ standard<br />

library. C-style strings are always a risk, because even C++ doesn’t know how much<br />

memory is allocated to a string. Consider the following C++ program:<br />

#include <br />

// WARNING: This code has a buffer overflow in it.<br />

int main(int argc, char *argv[]) {<br />

char buf[12];<br />

cin >> buf;<br />

cout

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!