public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v1] nscd: Fix double free in netgroupcache [BZ #27462]
@ 2021-02-25 21:13 DJ Delorie
  2021-03-01  7:48 ` Siddhesh Poyarekar
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: DJ Delorie @ 2021-02-25 21:13 UTC (permalink / raw)
  To: libc-alpha


In commit 745664bd798ec8fd50438605948eea594179fba1 a use-after-free
was fixed, but this led to an occasional double-free.  This patch
tracks the "live" allocation better.

Tested manually by a third party.

Related: RHBZ 1927877
---
 nscd/netgroupcache.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
index dba6ceec1b..ad2daddafd 100644
--- a/nscd/netgroupcache.c
+++ b/nscd/netgroupcache.c
@@ -248,7 +248,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
 					     : NULL);
 				    ndomain = (ndomain ? newbuf + ndomaindiff
 					       : NULL);
-				    buffer = newbuf;
+				    *tofreep = buffer = newbuf;
 				  }
 
 				nhost = memcpy (buffer + bufused,
@@ -319,7 +319,7 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
 		    else if (status == NSS_STATUS_TRYAGAIN && e == ERANGE)
 		      {
 			buflen *= 2;
-			buffer = xrealloc (buffer, buflen);
+			*tofreep = buffer = xrealloc (buffer, buflen);
 		      }
 		    else if (status == NSS_STATUS_RETURN
 			     || status == NSS_STATUS_NOTFOUND
-- 
2.21.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-03-03 19:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-25 21:13 [PATCH v1] nscd: Fix double free in netgroupcache [BZ #27462] DJ Delorie
2021-03-01  7:48 ` Siddhesh Poyarekar
2021-03-02 17:38   ` DJ Delorie
2021-03-02 17:03 ` Carlos O'Donell
2021-03-03 12:19 ` Andreas Schwab
2021-03-03 17:11   ` DJ Delorie
2021-03-03 17:48     ` Andreas Schwab
2021-03-03 19:55       ` [PATCH v1] NEWS: Add entry for CVE-2021-27645 DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).