Coverity (CID
1660133, GH #3470) reports that dir may point to the
block-local tmpdir[] array after it has gone out of scope, since dir
is read again in the "Cannot chroot()" alert past the end of the
"chroot auto" if-block. Move tmpdir's declaration to function scope
so its lifetime covers every use of dir.
Must be backported to 3.4.
{
const char *dir, *chroot_dir;
int error, chroot_error;
+ char tmpdir[] = "/tmp/haproxy.XXXXXX";
error = chroot_error = 0;
dir = chroot_dir = path;
/* When "chroot auto" is used, we attempt to chroot to an
* anonymous and read-only directory.
*/
- char tmpdir[] = "/tmp/haproxy.XXXXXX";
dir = mkdtemp(tmpdir);
if (dir == NULL) {
ha_alert("[%s.main()] Cannot create(%s) for chroot auto.\n",