This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] Add reallocarray function.
On Mon, 17 Apr 2017, Dennis Wölfing 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>.
A patch adding a new function should also include NEWS file changes to
mention that new feature.
> diff --git a/malloc/reallocarray.c b/malloc/reallocarray.c
> new file mode 100644
> index 0000000000..4915ca7a7d
> --- /dev/null
> +++ b/malloc/reallocarray.c
> @@ -0,0 +1,35 @@
> +/* Copyright (C) 2017 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
New files should have a descriptive comment on their first line, before
the copyright notice.
> diff --git a/malloc/tst-reallocarray.c b/malloc/tst-reallocarray.c
> new file mode 100644
> index 0000000000..a43419b82b
> --- /dev/null
> +++ b/malloc/tst-reallocarray.c
> @@ -0,0 +1,160 @@
> +/* Copyright (C) 2014-2017 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
Likewise.
> +#define TEST_FUNCTION do_test ()
> +#include "../test-skeleton.c"
Please use the new-style support/test-driver.c for new tests.
--
Joseph S. Myers
joseph@codesourcery.com