]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
src/groupmems.c: Fix number of elements in allocation
authorAlejandro Colomar <alx@kernel.org>
Mon, 13 May 2024 12:46:47 +0000 (14:46 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 2 Jul 2024 02:40:11 +0000 (21:40 -0500)
We are setting `sgrent.sg_adm[1] = NULL;`, so we need 2 elements.

Fixes: 87b56b19fb72 ("* NEWS, src/groupmems.c, man/groupmems.8.xml: Added support for [...]")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/groupmems.c

index a369a619062d8def736a25af73a2376fb9d71622..0d0882db224b4befa6bd21867096601fc47bada4 100644 (file)
@@ -127,7 +127,7 @@ static void add_user (const char *user,
                        static struct sgrp sgrent;
                        sgrent.sg_name = xstrdup (newgrp->gr_name);
                        sgrent.sg_mem = dup_list (newgrp->gr_mem);
-                       sgrent.sg_adm = XMALLOC(1, char *);
+                       sgrent.sg_adm = XMALLOC(2, char *);
 #ifdef FIRST_MEMBER_IS_ADMIN
                        if (sgrent.sg_mem[0]) {
                                sgrent.sg_adm[0] = xstrdup (sgrent.sg_mem[0]);
@@ -210,7 +210,7 @@ static void remove_user (const char *user,
                        static struct sgrp sgrent;
                        sgrent.sg_name = xstrdup (newgrp->gr_name);
                        sgrent.sg_mem = dup_list (newgrp->gr_mem);
-                       sgrent.sg_adm = XMALLOC(1, char *);
+                       sgrent.sg_adm = XMALLOC(2, char *);
 #ifdef FIRST_MEMBER_IS_ADMIN
                        if (sgrent.sg_mem[0]) {
                                sgrent.sg_adm[0] = xstrdup (sgrent.sg_mem[0]);