[PATCH] Add reallocarray function.
Dennis Wölfing
denniswoelfing@gmx.de
Mon Apr 10 18:27:00 GMT 2017
On 10.04.2017 17:18, Zack Weinberg wrote:
> On Mon, Apr 10, 2017 at 11:00 AM, Dennis Wölfing <denniswoelfing@gmx.de> wrote:
>> The reallocarray function is an extension from OpenBSD. It is an
>> integer-overflow-safe replacement for realloc(p, X*Y) and
>> malloc(X*Y) (realloc(NULL, X*Y)). It can therefore help in preventing
>> certain security issues in code.
>>
>> This is an updated version of a patch originally submitted by Rüdiger
>> Sonderfeld in May 2014.
>> See <https://sourceware.org/ml/libc-alpha/2014-05/msg00481.html>.
>
> I agree in principle with adding this function. I skimmed the patch
> and it seems to be mostly the Right Thing. I do have two concerns:
>
> * There do not appear to be any uses of the internal aliases
> __libc_reallocarray and __reallocarray. Have you audited glibc itself
> for places that should use reallocarray? If you haven't, would you be
> willing to do that? This will determine whether we actually need
> those aliases.
I have not yet checked where glibc itself should use reallocarray but I
will do so.
> * Please add documentation for reallocarray. It belongs in
> manual/memory.texi, in the "Changing Block Size" section. This is the
> place to explain when and why one should use reallocarray instead of
> realloc.
Ok, I will look into this.
More information about the Libc-alpha
mailing list