Project

General

Profile

Bug #11179

Inconsistent Addrinfo parsing a port number

Added by ibenza (Shin'ya Ueoka) over 4 years ago. Updated over 4 years ago.

Status:
Third Party's Issue
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-05-25 trunk 50637) [x86_64-linux]
[ruby-core:69353]

Description

In the case of the following code, ip_port returns 34464 because the number 99999 is cast as short int.
Is the result expected?

require 'socket'
Addrinfo.tcp('', 99999).ip_port    # => 34463

Even if the above behavior is correct, ip_port should return 65535 in the following code. But actually, Addrinfo raises an exception because -1 is parsed as service name. This behavior is inconsistent with the above.

require 'socket'
Addrinfo.tcp('', -1).ip_port     # => Servname not supported for ai_socktype (SocketError)

Associated revisions

Revision 2f8d3280
Added by akr (Akira Tanaka) over 4 years ago

  • ext/socket/raddrinfo.c (parse_numeric_port): Detect port overflow. (numeric_getaddrinfo): Use parse_numeric_port. numeric_getaddrinfo fails if port is too big now. This makes rb_getaddrinfo invokes the real getaddrinfo() on such condition. This change is related to [ruby-core:69355] [Bug #11179].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 50890
Added by akr (Akira Tanaka) over 4 years ago

  • ext/socket/raddrinfo.c (parse_numeric_port): Detect port overflow. (numeric_getaddrinfo): Use parse_numeric_port. numeric_getaddrinfo fails if port is too big now. This makes rb_getaddrinfo invokes the real getaddrinfo() on such condition. This change is related to [ruby-core:69355] [Bug #11179].

Revision 50890
Added by akr (Akira Tanaka) over 4 years ago

  • ext/socket/raddrinfo.c (parse_numeric_port): Detect port overflow. (numeric_getaddrinfo): Use parse_numeric_port. numeric_getaddrinfo fails if port is too big now. This makes rb_getaddrinfo invokes the real getaddrinfo() on such condition. This change is related to [ruby-core:69355] [Bug #11179].

Revision 50890
Added by akr (Akira Tanaka) over 4 years ago

  • ext/socket/raddrinfo.c (parse_numeric_port): Detect port overflow. (numeric_getaddrinfo): Use parse_numeric_port. numeric_getaddrinfo fails if port is too big now. This makes rb_getaddrinfo invokes the real getaddrinfo() on such condition. This change is related to [ruby-core:69355] [Bug #11179].

Revision 50890
Added by akr (Akira Tanaka) over 4 years ago

  • ext/socket/raddrinfo.c (parse_numeric_port): Detect port overflow. (numeric_getaddrinfo): Use parse_numeric_port. numeric_getaddrinfo fails if port is too big now. This makes rb_getaddrinfo invokes the real getaddrinfo() on such condition. This change is related to [ruby-core:69355] [Bug #11179].

Revision 50890
Added by akr (Akira Tanaka) over 4 years ago

  • ext/socket/raddrinfo.c (parse_numeric_port): Detect port overflow. (numeric_getaddrinfo): Use parse_numeric_port. numeric_getaddrinfo fails if port is too big now. This makes rb_getaddrinfo invokes the real getaddrinfo() on such condition. This change is related to [ruby-core:69355] [Bug #11179].

History

Updated by ibenza (Shin'ya Ueoka) over 4 years ago

  • Subject changed from Addrinfo parsing a port number to Inconsistent Addrinfo parsing a port number

Updated by akr (Akira Tanaka) over 4 years ago

  • Status changed from Open to Third Party's Issue

The behavior is inherited from getaddrinfo() function in libc.
So it is difficult to fix the problem in Ruby.

Also available in: Atom PDF