malloc and buffer overflow attacks

Adam Ruppe destructionator at
Fri Dec 31 02:26:05 UTC 2021

On Friday, 31 December 2021 at 01:02:36 UTC, H. S. Teoh wrote:
> [0 .. len * T.sizeof)] would be safe from buffer overruns.

If you do this correctly on the byte before casting you SHOULD be 
ok because if the malloc overflows, so will the slice 
calculation, meaning you get the RangeError when you try to use 
it, which is what we want.

But since I screwed it up twice already i say this is evidence to 
just use `new` and find joy :P

More information about the Digitalmars-d mailing list