views:

78

answers:

1

how the stackoverflow affect variable ?

+2  A: 

A stack overflow normally means that your application will exit immediately. Therefore the effect will be that all process-related memory will be released, including your variables.

0xA3
Despite the most common scenario certainly being a complete failure followed by exit, in another occasion it means your application may be exploited, giving the attacker one (or various) chance to get into your machine, or elevate privileges. On a still less common scenario, it may just behave badly because the overwritten buffer didn't affect any stack frame, or luckily enough (or not) it wrote valid values over the affected region. This may influence the flow of your code by evaluating true on some conditions that it normally wouldn't, thus causing unexpected code execution.
jweyrich
@jweyrich: it seems you are confusing a stack overflow with a buffer overflow.
0xA3
@0xA3: stack overflow may be a form of buffer overflow, but if stack overflow here means allocating memory that exceeds the stack limit, you can handle it (e.g: a recursive function that exceeds the stack space). The application doesn't necessarily exit with failure
jweyrich