2 ms·
I don't think heap overflows are particularly safer than stack overflows. If anything, more dangerous on most systems, since at least stack cookies are fairly c
by tedunangst 12y ago
I don't think heap overflows are particularly safer than stack overflows. If anything, more dangerous on most systems, since at least stack cookies are fairly common. Heap protection is harder to find.
- jacquesm 12y agoAgreed, so in this particular case I would have allocated those buffers statically but scoped to the function (so outside the heap). Feel free to call me paranoid ;) I'd have added a sentinel as well.
- tedunangst 12y agoLocally scoped statics are still the moral equivalent of globals, and a waiting landmine for anyone who might ever run this code in a multithreaded environment.
- jacquesm 12y agoYes, that's definitely a problem. But switching from single threading to multi-threading should trigger a complete review of all the underlying code. That's not a trivial change and likely to break very many things if the assumption was that the code would be single threaded. Every data structure would need to be inspected.
- makomk 12y agoStatic buffers have even less protections than the stack or the heap. On many Linux and BSD systems, static variables don't even have ASLR applied to them if they're in an executable rather than a library.
- jacquesm 12y agoYes, because as a rule it is much harder to get execution of arbitrary code out of an overflow in a buffer allocated like that. The protections are there where they are needed most.