diff options
author | Florian Weimer <fweimer@redhat.com> | 2024-04-25 15:00:45 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2024-04-25 15:52:33 +0200 |
commit | 52f73e5c4e29b14e79167272297977f360ae1e97 (patch) | |
tree | 0d10322bd878b69db613befd84d4e4c6c03f4bfd | |
parent | a8b0561db4b9847ebfbfec20075697d5492a363c (diff) | |
download | glibc-52f73e5c4e29b14e79167272297977f360ae1e97.zip glibc-52f73e5c4e29b14e79167272297977f360ae1e97.tar.gz glibc-52f73e5c4e29b14e79167272297977f360ae1e97.tar.bz2 |
CVE-2024-33599: nscd: Stack-based buffer overflow in netgroup cache (bug 31677)
Using alloca matches what other caches do. The request length is
bounded by MAXKEYLEN.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 87801a8fd06db1d654eea3e4f7626ff476a9bdaa)
-rw-r--r-- | nscd/netgroupcache.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c index 2f71bf2..f13a11b 100644 --- a/nscd/netgroupcache.c +++ b/nscd/netgroupcache.c @@ -503,12 +503,13 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req, = (struct indataset *) mempool_alloc (db, sizeof (*dataset) + req->key_len, 1); - struct indataset dataset_mem; bool cacheable = true; if (__glibc_unlikely (dataset == NULL)) { cacheable = false; - dataset = &dataset_mem; + /* The alloca is safe because nscd_run_worker verfies that + key_len is not larger than MAXKEYLEN. */ + dataset = alloca (sizeof (*dataset) + req->key_len); } datahead_init_pos (&dataset->head, sizeof (*dataset) + req->key_len, |