diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-23 07:16:20 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-10-23 07:16:20 +0000 |
commit | 409293eb09480ad5a1857496e0ad8147e2576057 (patch) | |
tree | 3de99560c234204dc54734d215acc160c1d0f7d6 /ext/socket | |
parent | 5a8db29b59f5f0bd6272bbfd615d356e475c52f1 (diff) | |
download | ruby-409293eb09480ad5a1857496e0ad8147e2576057.tar.gz |
* 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
Diffstat (limited to 'ext/socket')
-rw-r--r-- | ext/socket/socket.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c index a47c6d47df..09abc88c18 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -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); |