mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-01 10:06:57 +03:00
Update.
* posix/unistd.h (socklen_t): Define if it has not yet happened. (gethostname): Change type of second parameter to socklen_t. * include/unistd.h (__gethostname): Change type of second parameter to socklen_t. * sysdeps/generic/gethostname.c (__gethostname): Likewise. * sysdeps/mach/hurd/gethostname.c (__gethostname): Likewise. * sysdeps/unix/sysv/gethostname.c (__gethostname): Likewise. * sysdeps/unix/sysv/sysv4/solaris2/gethostname.c (__gethostname): Likewise. * sysdeps/unix/sysv/linux/gethostname.c: Removed. * sysdeps/generic/bits/socket.h: Use __socklen_t to define socklen_t. Allow definition elsewhere. * sysdeps/unix/sysv/aix/bits/socket.h: Likewise. * sysdeps/unix/sysv/linux/bits/socket.h: Likewise. * sysdeps/unix/sysv/linux/mips/bits/socket.h: Likewise. * sysdeps/generic/bits/types.h: Define __socklen_t. * sysdeps/unix/sysv/aix/bits/types.h: Likewise. * sysdeps/unix/sysv/hpux/bits/types.h: Likewise. * sysdeps/unix/sysv/linux/alpha/bits/types.h: Likewise. * sysdeps/unix/sysv/linux/bits/types.h: Likewise. * sysdeps/unix/sysv/linux/mips/bits/types.h: Likewise. * sysdeps/unix/sysv/linux/sparc/bits/types.h: Likewise. * sysdeps/unix/sysv/sysv4/solaris2/bits/types.h: Likewise.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 1992, 1995, 1997 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1992, 1995, 1997, 2000 Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
|
||||
The GNU C Library is free software; you can redistribute it and/or
|
||||
@ -17,6 +17,7 @@
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
@ -26,12 +27,22 @@
|
||||
int
|
||||
__gethostname (name, len)
|
||||
char *name;
|
||||
size_t len;
|
||||
socklen_t len;
|
||||
{
|
||||
struct utsname buf;
|
||||
size_t node_len;
|
||||
|
||||
if (uname (&buf))
|
||||
return -1;
|
||||
strncpy (name, buf.nodename, len);
|
||||
|
||||
node_len = strlen (buf.nodename) + 1;
|
||||
if (node_len > len)
|
||||
{
|
||||
__set_errno (ENAMETOOLONG);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy (name, buf.nodename, node_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user