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 | 67966d892c6a3ba05c848f4ade49fc7a278ed174 (patch) | |
| tree | 3de99560c234204dc54734d215acc160c1d0f7d6 /ext/socket | |
| parent | 537840d1ed5a847f749da664a4f544d7fa7d4e01 (diff) | |
| download | ruby-67966d892c6a3ba05c848f4ade49fc7a278ed174.tar.gz ruby-67966d892c6a3ba05c848f4ade49fc7a278ed174.tar.xz ruby-67966d892c6a3ba05c848f4ade49fc7a278ed174.zip | |
* ext/socket/socket.c (sock_s_getservbyport): check if the port range.
[ruby-core:19460]
git-svn-id: http://svn.ruby-lang.org/repos/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 a47c6d47d..09abc88c1 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); |
