1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
akr 2013-04-17 11:01:17 +00:00
parent cef6a377fc
commit ce6db8f286
3 changed files with 16 additions and 1 deletions

View file

@ -1,3 +1,10 @@
Wed Apr 17 20:00:18 2013 Tanaka Akira <akr@fsij.org>
* ext/socket/rubysocket.h (SOCKLEN_MAX): Defined.
* ext/socket/raddrinfo.c (ext/socket/raddrinfo.c): Reject too long
Linux abstract socket name.
Wed Apr 17 19:45:27 2013 Aman Gupta <tmm1@ruby-lang.org>
* iseq.c (iseq_location_setup): re-use existing string when iseq has

View file

@ -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

View file

@ -91,6 +91,12 @@
#ifndef HAVE_TYPE_SOCKLEN_T
typedef int socklen_t;
#endif
#define SOCKLEN_MAX \
(0 < (((socklen_t)0)-1) ? \
~(socklen_t)0 : \
(((((socklen_t)1) << (sizeof(socklen_t) * CHAR_BIT - 2)) - 1) * 2 + 1))
#ifndef RSTRING_SOCKLEN
# define RSTRING_SOCKLEN (socklen_t)RSTRING_LENINT
#endif