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>
  • Loading branch information
djdelorierh committed Mar 2, 2021
1 parent dd1776e commit dca5658
Showing 1 changed file with 2 additions and 2 deletions.
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 dca5658

Please sign in to comment.