digitalmars.D.learn - what is exactly stack stomp "-gx" new switch ?
- Klb (1/1) Jul 15 2014 ...and any example where this switch will be usefull ?
- bearophile (7/8) Jul 15 2014 I guess it was added to D in the spirit of "If you have to ask
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (31/38) Jul 15 2014 Just from the name of it, it sounds like the program stack will be
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (8/10) Jul 15 2014 Before others point out, those are in C syntax by mistake. :) They
Klb:...and any example where this switch will be usefull ?I guess it was added to D in the spirit of "If you have to ask what it is, then you don't need to use it". More seriously, I too would like more documentation about its use cases. Bye, bearophile
Jul 15 2014
On 07/15/2014 04:33 PM, bearophile wrote:Klb:Just from the name of it, it sounds like the program stack will be cleared at certain times, likely when exiting functions, to clear sensitive information. And my test supports that idea. Here is some malicious function trying to read data from the stack's earlier contents: import std.stdio; void foo(char c) { char buffer[100]; foreach (ref b; buffer) { b = c; } } void malicious() { char buffer[100] = void; writeln("Let's see what we'll find on the stack..."); foreach (b; buffer) { write(b); } writeln; } void main() { foo('a'); malicious(); } When I run the program without -gx, malicious() prints the contents that are left from foo()'s execution. Ali...and any example where this switch will be usefull ?I guess it was added to D in the spirit of "If you have to ask what it is, then you don't need to use it". More seriously, I too would like more documentation about its use cases. Bye, bearophile
Jul 15 2014
On 07/15/2014 04:56 PM, Ali Çehreli wrote:char buffer[100];[...]char buffer[100] = void;Before others point out, those are in C syntax by mistake. :) They should preferably be: char[100] buffer; [...] char[100] buffer = void; Ali
Jul 15 2014