4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-18 20:39:33 +08:00

* passwd.cc (getpwnam_r): Add pw_passwd handling as well.

(getpwuid_r): Ditto.
This commit is contained in:
Corinna Vinschen 2001-04-24 21:52:57 +00:00
parent 3c73ae1c1e
commit b7cf6a2f5b
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,8 @@
Tue Apr 24 23:51:00 2001 Corinna Vinschen <corinna@vinschen.de>
* passwd.cc (getpwnam_r): Add pw_passwd handling as well.
(getpwuid_r): Ditto.
Tue Apr 24 23:43:00 2001 Corinna Vinschen <corinna@vinschen.de> Tue Apr 24 23:43:00 2001 Corinna Vinschen <corinna@vinschen.de>
* passwd.cc (getpwnam_r): Use correct offsets into buffer. * passwd.cc (getpwnam_r): Use correct offsets into buffer.

View File

@ -231,7 +231,8 @@ getpwuid_r (uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct
/* check needed buffer size. */ /* check needed buffer size. */
size_t needsize = strlen (temppw->pw_name) + strlen (temppw->pw_dir) + size_t needsize = strlen (temppw->pw_name) + strlen (temppw->pw_dir) +
strlen (temppw->pw_shell) + strlen (temppw->pw_gecos) + 4; strlen (temppw->pw_shell) + strlen (temppw->pw_gecos) +
strlen (temppw->pw_passwd) + 5;
if (needsize > bufsize) if (needsize > bufsize)
return ERANGE; return ERANGE;
@ -243,10 +244,12 @@ getpwuid_r (uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct
pwd->pw_dir = pwd->pw_name + strlen (temppw->pw_name) + 1; pwd->pw_dir = pwd->pw_name + strlen (temppw->pw_name) + 1;
pwd->pw_shell = pwd->pw_dir + strlen (temppw->pw_dir) + 1; pwd->pw_shell = pwd->pw_dir + strlen (temppw->pw_dir) + 1;
pwd->pw_gecos = pwd->pw_shell + strlen (temppw->pw_shell) + 1; pwd->pw_gecos = pwd->pw_shell + strlen (temppw->pw_shell) + 1;
pwd->pw_passwd = pwd->pw_gecos + strlen (temppw->pw_gecos) + 1;
strcpy (pwd->pw_name, temppw->pw_name); strcpy (pwd->pw_name, temppw->pw_name);
strcpy (pwd->pw_dir, temppw->pw_dir); strcpy (pwd->pw_dir, temppw->pw_dir);
strcpy (pwd->pw_shell, temppw->pw_shell); strcpy (pwd->pw_shell, temppw->pw_shell);
strcpy (pwd->pw_gecos, temppw->pw_gecos); strcpy (pwd->pw_gecos, temppw->pw_gecos);
strcpy (pwd->pw_passwd, temppw->pw_passwd);
return 0; return 0;
} }
@ -286,7 +289,8 @@ getpwnam_r (const char *nam, struct passwd *pwd, char *buffer, size_t bufsize, s
/* check needed buffer size. */ /* check needed buffer size. */
size_t needsize = strlen (temppw->pw_name) + strlen (temppw->pw_dir) + size_t needsize = strlen (temppw->pw_name) + strlen (temppw->pw_dir) +
strlen (temppw->pw_shell) + strlen (temppw->pw_gecos) + 4; strlen (temppw->pw_shell) + strlen (temppw->pw_gecos) +
strlen (temppw->pw_passwd) + 5;
if (needsize > bufsize) if (needsize > bufsize)
return ERANGE; return ERANGE;
@ -298,10 +302,12 @@ getpwnam_r (const char *nam, struct passwd *pwd, char *buffer, size_t bufsize, s
pwd->pw_dir = pwd->pw_name + strlen (temppw->pw_name) + 1; pwd->pw_dir = pwd->pw_name + strlen (temppw->pw_name) + 1;
pwd->pw_shell = pwd->pw_dir + strlen (temppw->pw_dir) + 1; pwd->pw_shell = pwd->pw_dir + strlen (temppw->pw_dir) + 1;
pwd->pw_gecos = pwd->pw_shell + strlen (temppw->pw_shell) + 1; pwd->pw_gecos = pwd->pw_shell + strlen (temppw->pw_shell) + 1;
pwd->pw_passwd = pwd->pw_gecos + strlen (temppw->pw_gecos) + 1;
strcpy (pwd->pw_name, temppw->pw_name); strcpy (pwd->pw_name, temppw->pw_name);
strcpy (pwd->pw_dir, temppw->pw_dir); strcpy (pwd->pw_dir, temppw->pw_dir);
strcpy (pwd->pw_shell, temppw->pw_shell); strcpy (pwd->pw_shell, temppw->pw_shell);
strcpy (pwd->pw_gecos, temppw->pw_gecos); strcpy (pwd->pw_gecos, temppw->pw_gecos);
strcpy (pwd->pw_passwd, temppw->pw_passwd);
return 0; return 0;
} }