how to fix buffer overrun

Posted on 2008-11-07
Last Modified: 2013-12-14
I keep getting the massage saying that " A buffer overrun has been detected which has corrupted  the program's internal state. The program cannot safely continue execution and must now be terminated". How can I fix that problem? I'm not really good with computer so you need to show me every step clearly. Thank you.
Question by:havannguyen
    LVL 39

    Expert Comment

    First you must locate the issue in the source code. Easiest would be if the overrun occured in debug mode as well. Then, the debugger would throw an assertion and you could check the call stack to find out where the overrun had occured. It often is a strcpy or memcpy. It also could be a loop writing beyond buffer boundaries.

    if it happens in release mode only it is more difficult. You could call a log function (don't forgot to flush each message or open and close the logfile with each call) at begin of each function and at end. After the termination check your logfile and you know in which function the crash happened. Then, narrow the logs until you finally have located the statement. Post it here if you don't know why it crashes.
    LVL 5

    Accepted Solution

    You'd better replace all old-school functions like strcpy with safe ones like strcpy_n  which aredesigned specifically to reduce that kind of errors. Also, you may replace all your arrays and dynamic memory with STL data structures. You'd better dig around STL, very nice and productive thing.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    INTRODUCTION "Virut" is a nasty, polymorphic file infector, and it infects every executable and screensaver file on access.  Some variant also infects .htm, html, .rar and .zip archives, and latest variants infects php and asp.  It patches system…
    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now