posix: Remove dynamic memory allocation from execl{e,p}
commitf83bb9b8e97656ae0d3e2a31e859363e2d4d5832
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 29 Jan 2016 13:43:40 +0000 (29 11:43 -0200)
committerAdhemerval Zanella <adhemerval.zanella@linaro.com>
Mon, 7 Mar 2016 03:21:36 +0000 (7 00:21 -0300)
tree3360c4505fee657945315275c1a23d2347c52c08
parentfee9eb6200f0e44a4b684903bc47fde36d46f1a5
posix: Remove dynamic memory allocation from execl{e,p}

GLIBC execl{e,p} implementation might use malloc if the total number of
arguments exceed initial assumption size (1024).  This might lead to
issues in two situations:

1. execl/execle is stated to be async-signal-safe by POSIX [1].  However
   if execl is used in a signal handler with a large argument set (that
   may call malloc internally) and if the resulting call fails it might
   lead malloc in the program in a bad state.

2. If the functions are used in a vfork/clone(VFORK) situation it also
   might issue malloc internal bad state.

This patch fixes it by using stack allocation instead.  It also fixes
BZ#19534.

Tested on x86_64.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html

[BZ #19534]
* posix/execl.c (execl): Remove dynamic memory allocation.
* posix/execle.c (execle): Likewise.
* posix/execlp.c (execlp): Likewise.
ChangeLog
posix/execl.c
posix/execle.c
posix/execlp.c