mirror of
https://sourceware.org/git/glibc.git
synced 2025-10-21 14:53:53 +03:00
Adjust pointers to triplets in netgroup query data (BZ #16474)
The _nss_*_getnetgrent_r query populates the netgroup results in the allocated buffer and then sets the result triplet to point to strings in the buffer. This is a problem when the buffer is reallocated since the pointers to the triplet strings are no longer valid. The pointers need to be adjusted so that they now point to strings in the reallocated buffer.
This commit is contained in:
@@ -241,7 +241,17 @@ addgetnetgrentX (struct database_dyn *db, int fd, request_header *req,
|
||||
if (buflen - req->key_len - bufused < needed)
|
||||
{
|
||||
buflen += MAX (buflen, 2 * needed);
|
||||
buffer = xrealloc (buffer, buflen);
|
||||
char *newbuf = xrealloc (buffer, buflen);
|
||||
/* Adjust the pointers in the new
|
||||
buffer. */
|
||||
nhost = (nhost ? newbuf + (nhost - buffer)
|
||||
: NULL);
|
||||
nuser = (nuser ? newbuf + (nuser - buffer)
|
||||
: NULL);
|
||||
ndomain = (ndomain
|
||||
? newbuf + (ndomain - buffer)
|
||||
: NULL);
|
||||
buffer = newbuf;
|
||||
}
|
||||
|
||||
nhost = memcpy (buffer + bufused,
|
||||
|
Reference in New Issue
Block a user