mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
(cache_addpw): Use cope of original key in hash entry with alternative key.
This commit is contained in:
parent
25325c8541
commit
801ddb6a03
@ -133,7 +133,7 @@ cache_addpw (struct database *db, int fd, request_header *req, void *key,
|
||||
the response header and the dataset itself. */
|
||||
total = (sizeof (struct passwddata) + pw_name_len + pw_passwd_len
|
||||
+ pw_gecos_len + pw_dir_len + pw_shell_len);
|
||||
data = (struct passwddata *) malloc (total + n);
|
||||
data = (struct passwddata *) malloc (total + n + req->key_len);
|
||||
if (data == NULL)
|
||||
/* There is no reason to go on. */
|
||||
error (EXIT_FAILURE, errno, _("while allocating cache entry"));
|
||||
@ -157,9 +157,12 @@ cache_addpw (struct database *db, int fd, request_header *req, void *key,
|
||||
cp = mempcpy (cp, pwd->pw_dir, pw_dir_len);
|
||||
cp = mempcpy (cp, pwd->pw_shell, pw_shell_len);
|
||||
|
||||
/* Finally the stringified UID value. */
|
||||
/* Next the stringified UID value. */
|
||||
memcpy (cp, buf, n);
|
||||
|
||||
/* Copy of the key in case it differs. */
|
||||
char *key_copy = memcpy (cp + n, key, req->key_len);
|
||||
|
||||
/* We write the dataset before inserting it to the database
|
||||
since while inserting this thread might block and so would
|
||||
unnecessarily let the receiver wait. */
|
||||
@ -176,8 +179,8 @@ cache_addpw (struct database *db, int fd, request_header *req, void *key,
|
||||
total, data, 0, t, db, owner);
|
||||
|
||||
/* If the key is different from the name add a separate entry. */
|
||||
if (type == GETPWBYNAME && strcmp (key, data->strdata) != 0)
|
||||
cache_add (GETPWBYNAME, key, strlen (key) + 1, data,
|
||||
if (type == GETPWBYNAME && strcmp (key_copy, data->strdata) != 0)
|
||||
cache_add (GETPWBYNAME, key_copy, req->key_len, data,
|
||||
total, data, 0, t, db, owner);
|
||||
|
||||
cache_add (GETPWBYUID, cp, n, data, total, data, 1, t, db, owner);
|
||||
|
Loading…
Reference in New Issue
Block a user