malloc and buffer overflow attacks

Brian Callahan bcallah at openbsd.org
Mon Jan 3 00:52:38 UTC 2022


OpenBSD has had a function for a long time to deal with this 
exact problem. It's called reallocarray: 
https://man.openbsd.org/reallocarray

Don't let the name fool you--it handles both the initial 
allocation and reallocation.

Perhaps D should provide a similar function (not saying it has to 
be reallocarray). Asking people to fix their own code is a recipe 
for everyone creating different, subtly different and potentially 
incorrect, versions of a problem that should be solved once and 
then used by everyone.

~Brian


More information about the Digitalmars-d mailing list