|
|
Am 18.01.2013 19:30, schrieb Warp:
> clipka <ano### [at] anonymousorg> wrote:
>> So take an array with a limited size, an "int" as an index into that
>> array, a check whether that index into that array is smaller than the
>> array's size - and you have the recipe for a stack overflow or similar
>> (unless you also remember to check whether the index is non-negative).
>
> There's no index value that *could* be smaller than MIN_INT, so you would
> have a bug certainly (the program wrongly thinks that all indices are
> outside the array), but still no out-of-bounds access.
Okay, let's do it a bit more specific:
void fubar(int idx)
{
char c[1024];
if (idx < 1024)
fnord(c[idx]);
else
FAIL_SAFE();
}
void main()
{
fubar(INT_MAX+1);
}
No out-of-bounds access? Look at the code again.
Post a reply to this message
|
|