[前][次][番号順一覧][スレッド一覧]

ruby-changes:8367

From: nobu <ko1@a...>
Date: Thu, 23 Oct 2008 16:16:38 +0900 (JST)
Subject: [ruby-changes:8367] Ruby:r19898 (trunk): * ext/socket/socket.c (sock_s_getservbyport): check if the port range.

nobu	2008-10-23 16:16:20 +0900 (Thu, 23 Oct 2008)

  New Revision: 19898

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19898

  Log:
    * ext/socket/socket.c (sock_s_getservbyport): check if the port range.
      [ruby-core:19460]

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/socket.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19897)
+++ ChangeLog	(revision 19898)
@@ -1,3 +1,8 @@
+Thu Oct 23 16:16:17 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* ext/socket/socket.c (sock_s_getservbyname): unuse unnecessary
Index: ext/socket/socket.c
===================================================================
--- ext/socket/socket.c	(revision 19897)
+++ ext/socket/socket.c	(revision 19898)
@@ -3254,6 +3254,10 @@
 
     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);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]