]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
pam_cgfs: remove stack allocations
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 5 Feb 2019 06:33:48 +0000 (07:33 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 6 Feb 2019 10:47:57 +0000 (11:47 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/Makefile.am
src/lxc/pam/pam_cgfs.c

index 7d1522bf2c4b877d2715b1b428a13b9e5d3d57e0..6ba9ecad26b812613bfbc4a4c86501b75300af0a 100644 (file)
@@ -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
index 7bf57077bf9dff36eaf2384ae2a84b52ff14df99..1a377d7aa4fca195e9407041996ba97a782f42eb 100644 (file)
@@ -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';