pam_cgfs: remove stack allocations

parent 95ea3d1f
...@@ -433,6 +433,7 @@ pam_LTLIBRARIES = pam_cgfs.la ...@@ -433,6 +433,7 @@ pam_LTLIBRARIES = pam_cgfs.la
pam_cgfs_la_SOURCES = pam/pam_cgfs.c \ pam_cgfs_la_SOURCES = pam/pam_cgfs.c \
file_utils.c file_utils.h \ file_utils.c file_utils.h \
macro.h \ macro.h \
memory_utils.h \
string_utils.c string_utils.h string_utils.c string_utils.h
if !HAVE_STRLCAT if !HAVE_STRLCAT
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include "config.h" #include "config.h"
#include "file_utils.h" #include "file_utils.h"
#include "macro.h" #include "macro.h"
#include "memory_utils.h"
#include "string_utils.h" #include "string_utils.h"
#define PAM_SM_SESSION #define PAM_SM_SESSION
...@@ -845,8 +846,9 @@ static char **cgv1_get_proc_mountinfo_controllers(char **klist, char **nlist, ch ...@@ -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. */ /* Check if a cgroupfs v2 controller is present in the string @cgline. */
static bool cgv1_controller_in_clist(char *cgline, char *c) static bool cgv1_controller_in_clist(char *cgline, char *c)
{ {
__do_free char *tmp = NULL;
size_t len; size_t len;
char *tok, *eol, *tmp; char *tok, *eol;
char *saveptr = NULL; char *saveptr = NULL;
eol = strchr(cgline, ':'); eol = strchr(cgline, ':');
...@@ -854,7 +856,7 @@ static bool cgv1_controller_in_clist(char *cgline, char *c) ...@@ -854,7 +856,7 @@ static bool cgv1_controller_in_clist(char *cgline, char *c)
return false; return false;
len = eol - cgline; len = eol - cgline;
tmp = alloca(len + 1); tmp = must_realloc(NULL, len + 1);
memcpy(tmp, cgline, len); memcpy(tmp, cgline, len);
tmp[len] = '\0'; tmp[len] = '\0';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment