зеркало из https://github.com/github/ruby.git
* ext/socket/socket.c (sock_s_unpack_sockaddr_in): reject
non-AF_INET/AF_INET6 sockaddr. (sock_s_unpack_sockaddr_un): reject non-AF_UNIX sockaddr. [ruby-dev:28691] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
219a6edf8f
Коммит
8b074b2442
|
@ -1,3 +1,10 @@
|
|||
Mon Jun 5 18:12:12 2006 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* ext/socket/socket.c (sock_s_unpack_sockaddr_in): reject
|
||||
non-AF_INET/AF_INET6 sockaddr.
|
||||
(sock_s_unpack_sockaddr_un): reject non-AF_UNIX sockaddr.
|
||||
[ruby-dev:28691]
|
||||
|
||||
Sun Jun 4 20:40:19 2006 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* ext/socket/socket.c: fix sockaddr_un handling.
|
||||
|
|
|
@ -3512,6 +3512,17 @@ sock_s_unpack_sockaddr_in(self, addr)
|
|||
VALUE host;
|
||||
|
||||
sockaddr = (struct sockaddr_in*)StringValuePtr(addr);
|
||||
if (((struct sockaddr *)sockaddr)->sa_family != AF_INET
|
||||
#ifdef INET6
|
||||
&& ((struct sockaddr *)sockaddr)->sa_family != AF_INET6
|
||||
#endif
|
||||
) {
|
||||
#ifdef INET6
|
||||
rb_raise(rb_eArgError, "not an AF_INET/AF_INET6 sockaddr");
|
||||
#else
|
||||
rb_raise(rb_eArgError, "not an AF_INET sockaddr");
|
||||
#endif
|
||||
}
|
||||
host = make_ipaddr((struct sockaddr*)sockaddr);
|
||||
OBJ_INFECT(host, addr);
|
||||
return rb_assoc_new(INT2NUM(ntohs(sockaddr->sin_port)), host);
|
||||
|
@ -3549,6 +3560,9 @@ sock_s_unpack_sockaddr_un(self, addr)
|
|||
VALUE path;
|
||||
|
||||
sockaddr = (struct sockaddr_un*)StringValuePtr(addr);
|
||||
if (((struct sockaddr *)sockaddr)->sa_family != AF_UNIX) {
|
||||
rb_raise(rb_eArgError, "not an AF_UNIX sockaddr");
|
||||
}
|
||||
if (sizeof(struct sockaddr_un) < RSTRING(addr)->len) {
|
||||
rb_raise(rb_eTypeError, "too long sockaddr_un - %ld longer than %d",
|
||||
RSTRING(addr)->len, sizeof(struct sockaddr_un));
|
||||
|
|
|
@ -72,3 +72,12 @@ class TestBasicSocket < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
end if defined?(Socket)
|
||||
|
||||
class TestSocket < Test::Unit::TestCase
|
||||
def test_unpack_sockaddr
|
||||
sockaddr_in = Socket.sockaddr_in(80, "")
|
||||
assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(sockaddr_in) }
|
||||
sockaddr_un = Socket.sockaddr_un("/tmp/s")
|
||||
assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(sockaddr_un) }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#define RUBY_VERSION "1.9.0"
|
||||
#define RUBY_RELEASE_DATE "2006-06-04"
|
||||
#define RUBY_RELEASE_DATE "2006-06-05"
|
||||
#define RUBY_VERSION_CODE 190
|
||||
#define RUBY_RELEASE_CODE 20060604
|
||||
#define RUBY_RELEASE_CODE 20060605
|
||||
|
||||
#define RUBY_VERSION_MAJOR 1
|
||||
#define RUBY_VERSION_MINOR 9
|
||||
#define RUBY_VERSION_TEENY 0
|
||||
#define RUBY_RELEASE_YEAR 2006
|
||||
#define RUBY_RELEASE_MONTH 6
|
||||
#define RUBY_RELEASE_DAY 4
|
||||
#define RUBY_RELEASE_DAY 5
|
||||
|
||||
RUBY_EXTERN const char ruby_version[];
|
||||
RUBY_EXTERN const char ruby_release_date[];
|
||||
|
|
Загрузка…
Ссылка в новой задаче