Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can any one explain what is multiple integer overflow vulnerability with C# example?
Posted

Here's a very simple example:
C#
public class Program {
    static void Main(string[] args) {
        Charge(int.MaxValue);
    }

    private static void Charge(int amount) {
        int processingFee = 10;
        Console.WriteLine("Balance: " + -(amount + processingFee));
    }
}

We see a very large balance ;-)
 
Share this answer
 
When I googled this (like you should have), I found this:

In some situations a program may make the assumption that a variable always contains a positive value. If the variable has a signed integer type an overflow can cause its value to wrap and become negative, violating the assumption contained in the program and perhaps leading to unintended behavior. Similarly, subtracting from a small unsigned value may cause it to wrap to a large positive value which may also be an unexpected behavior. Multiplying or adding two integers may result in a value that is non-negative, but unexpectedly small. If this number is used as the number of bytes to allocate for a buffer, the buffer will be allocated unexpectedly small, leading to a potential buffer overflow.

I leav it to you to do the rest of your research.
 
Share this answer
 
then may i know wat is the difference between integer overflow and multiple integer overflow?
 
Share this answer
 
My guess would be having more than one...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900