aboutsummaryrefslogtreecommitdiff
path: root/nscd/netgroupcache.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2014-10-22 13:17:20 -0700
committerRoland McGrath <roland@hack.frob.com>2014-10-22 14:28:51 -0700
commitc6dfed243e0310bc3294c0fdf1816fceab024e9b (patch)
treebd587772105572514a6ed22a7ea1a82e8ede8e1f /nscd/netgroupcache.c
parent8c2b1ed8bbd20d35314c2a602b903159fa567ffb (diff)
downloadglibc-c6dfed243e0310bc3294c0fdf1816fceab024e9b.zip
glibc-c6dfed243e0310bc3294c0fdf1816fceab024e9b.tar.gz
glibc-c6dfed243e0310bc3294c0fdf1816fceab024e9b.tar.bz2
Rework some nscd code not to use variable-length struct types.
Diffstat (limited to 'nscd/netgroupcache.c')
-rw-r--r--nscd/netgroupcache.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
index edab174..9910c57 100644
--- a/nscd/netgroupcache.c
+++ b/nscd/netgroupcache.c
@@ -21,6 +21,7 @@
#include <errno.h>
#include <libintl.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
@@ -136,11 +137,8 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
char *buffer = NULL;
size_t nentries = 0;
size_t group_len = strlen (key) + 1;
- union
- {
- struct name_list elem;
- char mem[sizeof (struct name_list) + group_len];
- } first_needed;
+ struct name_list *first_needed
+ = alloca (sizeof (struct name_list) + group_len);
if (netgroup_database == NULL
&& __nss_database_lookup ("netgroup", NULL, NULL, &netgroup_database))
@@ -153,9 +151,9 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
memset (&data, '\0', sizeof (data));
buffer = xmalloc (buflen);
- first_needed.elem.next = &first_needed.elem;
- memcpy (first_needed.elem.name, key, group_len);
- data.needed_groups = &first_needed.elem;
+ first_needed->next = first_needed;
+ memcpy (first_needed->name, key, group_len);
+ data.needed_groups = first_needed;
while (data.needed_groups != NULL)
{