Normal use:
------(buffer)------ --(ret)--- DDDDDDDDEEEEEEEEEEEE EEEE FFFF 89ABCDEF0123456789AB CDEF 0123 this is a string\0 bff5 a400
Stack overflowed:
------(buffer)------ --(ret)--- DDDDDDDDEEEEEEEEEEEE EEEE FFFF 89ABCDEF0123456789AB CDEF 0123 oh no you got hacked cadf aff0 \0
Could you prevent this by putting the initial value of the string in the last (or, if there are other variables, closest to last) memory slot (EB) and making each subsequent letter each previous slot? E.g.
------(buffer)------ --(ret)--- DDDDDDDDEEEEEEEEEEEE EEEE FFFF 89ABCDEF0123456789AB CDEF 0123 dekcah tog uoy on ho bff5 a400 (no harm to ret pointer)
I understand there are better and more widely-accepted stack overflow preempts (canaries, noexec, ASLR). I'm just wondering. Would this fix the problem? Would it be technically feasible?