summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-12 16:00:03 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-12 16:00:03 +0000
commit91ff87c05df679b84ba4c537a71b10cd9e2b9613 (patch)
tree62a24bb3648bfde88da9ba2f297cedb950f32b5f /ext
parent73757753aef81b97b69a82ccbbcdd7fcfafc6e16 (diff)
* ext/socket/socket.c (sock_s_unpack_sockaddr_in): check too short
sockaddr. (sock_s_unpack_sockaddr_un): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21469 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/socket/socket.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index b161f038f66..098fd3a8c50 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -4328,6 +4328,11 @@ sock_s_unpack_sockaddr_in(VALUE self, VALUE addr)
VALUE host;
sockaddr = (struct sockaddr_in*)SockAddrStringValuePtr(addr);
+ if (RSTRING_LEN(addr) <
+ (char*)&((struct sockaddr *)sockaddr)->sa_family +
+ sizeof(((struct sockaddr *)sockaddr)->sa_family) -
+ (char*)sockaddr)
+ rb_raise(rb_eArgError, "too short sockaddr");
if (((struct sockaddr *)sockaddr)->sa_family != AF_INET
#ifdef INET6
&& ((struct sockaddr *)sockaddr)->sa_family != AF_INET6
@@ -4397,6 +4402,11 @@ sock_s_unpack_sockaddr_un(VALUE self, VALUE addr)
VALUE path;
sockaddr = (struct sockaddr_un*)SockAddrStringValuePtr(addr);
+ if (RSTRING_LEN(addr) <
+ (char*)&((struct sockaddr *)sockaddr)->sa_family +
+ sizeof(((struct sockaddr *)sockaddr)->sa_family) -
+ (char*)sockaddr)
+ rb_raise(rb_eArgError, "too short sockaddr");
if (((struct sockaddr *)sockaddr)->sa_family != AF_UNIX) {
rb_raise(rb_eArgError, "not an AF_UNIX sockaddr");
}