mirror of git://sourceware.org/git/glibc.git
Hurd: compliance fixes for getlogin_r
- make LOGIN non-static, as it would make getlogin_r no more reentrant; change its type to string_t - fail with ERANGE if NAME has not enough space for the actual login string - copy with memcpy only the chars of the string
This commit is contained in:
parent
0ced335ac0
commit
b3404dbdeb
|
@ -13,6 +13,10 @@
|
||||||
* sysdeps/mach/hurd/getgroups.c: Return -1 and set EINVAL for
|
* sysdeps/mach/hurd/getgroups.c: Return -1 and set EINVAL for
|
||||||
negative N or less than NGIDS.
|
negative N or less than NGIDS.
|
||||||
|
|
||||||
|
* sysdeps/mach/hurd/getlogin_r.c: Make LOGIN non-static and change its
|
||||||
|
type to string_t. Set ERANGE as errno and return it if NAME is not big
|
||||||
|
enough. Use memcpy instead of strncpy.
|
||||||
|
|
||||||
2012-07-20 Joseph Myers <joseph@codesourcery.com>
|
2012-07-20 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
* elf/Makefile (check-data): Remove.
|
* elf/Makefile (check-data): Remove.
|
||||||
|
|
|
@ -29,13 +29,20 @@ getlogin_r (name, name_len)
|
||||||
char *name;
|
char *name;
|
||||||
size_t name_len;
|
size_t name_len;
|
||||||
{
|
{
|
||||||
static char login[1024]; /* XXX */
|
string_t login;
|
||||||
error_t err;
|
error_t err;
|
||||||
|
|
||||||
if (err = __USEPORT (PROC, __proc_getlogin (port, login)))
|
if (err = __USEPORT (PROC, __proc_getlogin (port, login)))
|
||||||
return errno = err;
|
return errno = err;
|
||||||
|
|
||||||
strncpy (name, login, name_len);
|
size_t len = __strnlen (login, sizeof login - 1) + 1;
|
||||||
|
if (len > name_len)
|
||||||
|
{
|
||||||
|
errno = ERANGE;
|
||||||
|
return errno;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy (name, login, len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
libc_hidden_def (getlogin_r)
|
libc_hidden_def (getlogin_r)
|
||||||
|
|
Loading…
Reference in New Issue