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