summaryrefslogtreecommitdiff
path: root/ext/socket/raddrinfo.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-17 11:01:17 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-17 11:01:17 +0000
commitce6db8f286160fbf71c409416bd43c229b874601 (patch)
treee3ecd729b24a4746f8541954584b890404b7ecf0 /ext/socket/raddrinfo.c
parentcef6a377fcae99d062b2c7d9e0db2c07719c6975 (diff)
* ext/socket/rubysocket.h (SOCKLEN_MAX): Defined.
* ext/socket/raddrinfo.c (ext/socket/raddrinfo.c): Reject too long Linux abstract socket name. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40335 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/raddrinfo.c')
-rw-r--r--ext/socket/raddrinfo.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c
index d0d4d85..327218f 100644
--- a/ext/socket/raddrinfo.c
+++ b/ext/socket/raddrinfo.c
@@ -450,8 +450,10 @@ rsock_unix_sockaddr_len(VALUE path)
}
else if (RSTRING_PTR(path)[0] == '\0') {
/* abstract namespace; see unix(7) for details. */
+ if (SOCKLEN_MAX - offsetof(struct sockaddr_un, sun_path) < (size_t)RSTRING_LEN(path))
+ rb_raise(rb_eArgError, "Linux abstract socket too long");
return (socklen_t) offsetof(struct sockaddr_un, sun_path) +
- RSTRING_LEN(path);
+ RSTRING_SOCKLEN(path);
}
else {
#endif