mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/socket.c (sock_s_getservbyport): check if the port range.
[ruby-core:19460] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19898 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5a8db29b59
commit
409293eb09
2 changed files with 9 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Thu Oct 23 16:16:17 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/socket/socket.c (sock_s_getservbyport): check if the port range.
|
||||
[ruby-core:19460]
|
||||
|
||||
Thu Oct 23 14:08:07 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/socket/socket.c (sock_s_getservbyname): unuse unnecessary
|
||||
|
|
|
@ -3254,6 +3254,10 @@ sock_s_getservbyport(int argc, VALUE *argv)
|
|||
|
||||
rb_scan_args(argc, argv, "11", &port, &proto);
|
||||
portnum = NUM2LONG(port);
|
||||
if (portnum != (uint16_t)portnum) {
|
||||
const char *s = portnum > 0 ? "big" : "small";
|
||||
rb_raise(rb_eRangeError, "integer %ld too %s to convert into `int16_t'", portnum, s);
|
||||
}
|
||||
if (!NIL_P(proto)) protoname = StringValueCStr(proto);
|
||||
|
||||
sp = getservbyport((int)htons((uint16_t)portnum), protoname);
|
||||
|
|
Loading…
Add table
Reference in a new issue