|
|
8a984d |
commit dca565886b5e8bd7966e15f0ca42ee5cff686673
|
|
|
8a984d |
Author: DJ Delorie <dj@redhat.com>
|
|
|
8a984d |
Date: Thu Feb 25 16:08:21 2021 -0500
|
|
|
8a984d |
|
|
|
8a984d |
nscd: Fix double free in netgroupcache [BZ #27462]
|
|
|
8a984d |
|
|
|
8a984d |
In commit 745664bd798ec8fd50438605948eea594179fba1 a use-after-free
|
|
|
8a984d |
was fixed, but this led to an occasional double-free. This patch
|
|
|
8a984d |
tracks the "live" allocation better.
|
|
|
8a984d |
|
|
|
8a984d |
Tested manually by a third party.
|
|
|
8a984d |
|
|
|
8a984d |
Related: RHBZ 1927877
|
|
|
8a984d |
|
|
|
8a984d |
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
|
|
|
8a984d |
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
|
|
|
8a984d |
|
|
|
8a984d |
diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
|
|
|
8a984d |
index f521df824102bbca..5ee4413ef9384ec9 100644
|
|
|
8a984d |
--- a/nscd/netgroupcache.c
|
|
|
8a984d |
+++ b/nscd/netgroupcache.c
|
|
|
8a984d |
@@ -248,7 +248,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
|
|
|
8a984d |
: NULL);
|
|
|
8a984d |
ndomain = (ndomain ? newbuf + ndomaindiff
|
|
|
8a984d |
: NULL);
|
|
|
8a984d |
- buffer = newbuf;
|
|
|
8a984d |
+ *tofreep = buffer = newbuf;
|
|
|
8a984d |
}
|
|
|
8a984d |
|
|
|
8a984d |
nhost = memcpy (buffer + bufused,
|
|
|
8a984d |
@@ -319,7 +319,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
|
|
|
8a984d |
else if (status == NSS_STATUS_TRYAGAIN && e == ERANGE)
|
|
|
8a984d |
{
|
|
|
8a984d |
buflen *= 2;
|
|
|
8a984d |
- buffer = xrealloc (buffer, buflen);
|
|
|
8a984d |
+ *tofreep = buffer = xrealloc (buffer, buflen);
|
|
|
8a984d |
}
|
|
|
8a984d |
else if (status == NSS_STATUS_RETURN
|
|
|
8a984d |
|| status == NSS_STATUS_NOTFOUND
|