Skip to content

Commit

Permalink
nscd: Fix double free in netgroupcache [BZ #27462]
Browse files Browse the repository at this point in the history
In commit 745664b 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

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit dca5658)
  • Loading branch information
djdelorierh authored and ldv-alt committed Mar 8, 2021
1 parent 2777e19 commit c49cbcd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions NEWS
Expand Up @@ -99,6 +99,11 @@ Security related changes:
CVE-2020-29562: An assertion failure has been fixed in the iconv function
when invoked with UCS4 input containing an invalid character.

CVE-2021-27645: The nameserver caching daemon (nscd), when processing
a request for netgroup lookup, may crash due to a double-free,
potentially resulting in degraded service or Denial of Service on the
local system. Reported by Chris Schanzle.

The following bugs are resolved with this release:

[6889] 'PWD' mentioned but not specified
Expand Down Expand Up @@ -195,6 +200,7 @@ The following bugs are resolved with this release:
character sets (CVE-2020-27618)
[26383] bind_textdomain_codeset doesn't accept //TRANSLIT anymore
[26923] Assertion failure in iconv when converting invalid UCS4 (CVE-2020-29562)
[27462] nscd: double-free in nscd (CVE-2021-27645)


Version 2.27
Expand Down
4 changes: 2 additions & 2 deletions nscd/netgroupcache.c
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c49cbcd

Please sign in to comment.