From: Christian Brauner Date: Tue, 5 Feb 2019 06:33:48 +0000 (+0100) Subject: pam_cgfs: remove stack allocations X-Git-Tag: lxc-3.2.0~164^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6421783a266717eca422dd4cf6a5139ca95094ee;p=thirdparty%2Flxc.git pam_cgfs: remove stack allocations Signed-off-by: Christian Brauner --- diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am index 7d1522bf2..6ba9ecad2 100644 --- a/src/lxc/Makefile.am +++ b/src/lxc/Makefile.am @@ -433,6 +433,7 @@ pam_LTLIBRARIES = pam_cgfs.la pam_cgfs_la_SOURCES = pam/pam_cgfs.c \ file_utils.c file_utils.h \ macro.h \ + memory_utils.h \ string_utils.c string_utils.h if !HAVE_STRLCAT diff --git a/src/lxc/pam/pam_cgfs.c b/src/lxc/pam/pam_cgfs.c index 7bf57077b..1a377d7aa 100644 --- a/src/lxc/pam/pam_cgfs.c +++ b/src/lxc/pam/pam_cgfs.c @@ -59,6 +59,7 @@ #include "config.h" #include "file_utils.h" #include "macro.h" +#include "memory_utils.h" #include "string_utils.h" #define PAM_SM_SESSION @@ -845,8 +846,9 @@ static char **cgv1_get_proc_mountinfo_controllers(char **klist, char **nlist, ch /* Check if a cgroupfs v2 controller is present in the string @cgline. */ static bool cgv1_controller_in_clist(char *cgline, char *c) { + __do_free char *tmp = NULL; size_t len; - char *tok, *eol, *tmp; + char *tok, *eol; char *saveptr = NULL; eol = strchr(cgline, ':'); @@ -854,7 +856,7 @@ static bool cgv1_controller_in_clist(char *cgline, char *c) return false; len = eol - cgline; - tmp = alloca(len + 1); + tmp = must_realloc(NULL, len + 1); memcpy(tmp, cgline, len); tmp[len] = '\0';