From 47cae946df8f721aff48d63275ee29b90dccb87a Mon Sep 17 00:00:00 2001 From: Klas Lindfors Date: Thu, 19 Sep 2013 08:34:04 +0200 Subject: [PATCH] allocate space for the grplist in the privs structure as we want to save the privs structure longer than the scope of def_privs we need to allocate the space for grplist. --- drop_privs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drop_privs.c b/drop_privs.c index 5268966..ff5da5e 100644 --- a/drop_privs.c +++ b/drop_privs.c @@ -65,7 +65,13 @@ static struct pam_modutil_privs * _privs_location(int force_init) { static struct pam_modutil_privs privs; if (init == 0 || force_init) { PAM_MODUTIL_DEF_PRIVS(def_privs); + if(privs.grplist) { + free(privs.grplist); + } privs = def_privs; + /* since we want to save the information longer than the lifetime of dev_privs + * we need to allocate space for the grplist.. */ + privs.grplist = malloc(def_privs.number_of_groups * sizeof(gid_t)); init = 1; } return &privs;