K1u Posted December 8, 2007 Share Posted December 8, 2007 Something I wrote for a new section on my site, angablade might make some on vulns in php soon. Vulnerable: #include <iostream> int main(void) { char ownme[255] = { 0 }; std::cin >> ownme; getchar(); } Solution: The code may be exploited by entering a value of 256 chars, causing just one form of a very basic Buffer Overflow. This occurs logically due to more going in than meant to go in. This concept may not be easy to all, so I will explain through a example, if I were to fill a balloon with more air than it could take it would explode, very simple example to understand. More information: Buffer Overflow - http://en.wikipedia.org/wiki/Buffer_overflow Writing a secure version of the code: #include <iostream> int main(void) { char hahacantownme[256] = { 0 }; std::cin.getline(hahacantownme, 255); getchar(); } Notice that I use the max which is 256 and only permit to get 1 lower than this. I hope you enjoyed and also learned something. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.