mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/socket.c (sock_gethostname): Use NI_MAXHOST to support
hostnames longer than 64 characters if the system supports it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
97e37d6805
commit
73ac899b7f
2 changed files with 13 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Jul 25 13:18:00 2014 Will Farrington <wfarrington@digitalocean.com>
|
||||
|
||||
* ext/socket/socket.c (sock_gethostname): Use NI_MAXHOST to support
|
||||
hostnames longer than 64 characters if the system supports it.
|
||||
|
||||
Fri Jul 25 12:21:11 2014 Santiago Pastorino <santiago@wyeworks.com>
|
||||
|
||||
* compile.c (defined_expr): make the condition if the receiver
|
||||
|
|
|
@ -1023,10 +1023,15 @@ sock_sysaccept(VALUE sock)
|
|||
static VALUE
|
||||
sock_gethostname(VALUE obj)
|
||||
{
|
||||
#ifndef HOST_NAME_MAX
|
||||
# define HOST_NAME_MAX 1024
|
||||
#if defined(NI_MAXHOST)
|
||||
# define RUBY_MAX_HOST_NAME_LEN NI_MAXHOST
|
||||
#elif defined(HOST_NAME_MAX)
|
||||
# define RUBY_MAX_HOST_NAME_LEN HOST_NAME_MAX
|
||||
#else
|
||||
# define RUBY_MAX_HOST_NAME_LEN 1024
|
||||
#endif
|
||||
char buf[HOST_NAME_MAX+1];
|
||||
|
||||
char buf[RUBY_MAX_HOST_NAME_LEN+1];
|
||||
|
||||
rb_secure(3);
|
||||
if (gethostname(buf, (int)sizeof buf - 1) < 0)
|
||||
|
|
Loading…
Reference in a new issue