* ext/socket/raddrinfo.c (init_unix_addrinfo): show actual path length
when it is too long for Unix socket. * ext/socket/unixsocket.c (rsock_init_unixsock): ditto. * ext/socket/socket.c (sock_s_pack_sockaddr_un): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
606208becf
commit
7c346a46d3
@ -1,3 +1,12 @@
|
|||||||
|
Tue Apr 24 21:57:53 2012 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/socket/raddrinfo.c (init_unix_addrinfo): show actual path length
|
||||||
|
when it is too long for Unix socket.
|
||||||
|
|
||||||
|
* ext/socket/unixsocket.c (rsock_init_unixsock): ditto.
|
||||||
|
|
||||||
|
* ext/socket/socket.c (sock_s_pack_sockaddr_un): ditto.
|
||||||
|
|
||||||
Tue Apr 24 21:43:58 2012 Yusuke Endoh <mame@tsg.ne.jp>
|
Tue Apr 24 21:43:58 2012 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
* lib/net/smtp.rb (check_continue): raise an error with an explanatory
|
* lib/net/smtp.rb (check_continue): raise an error with an explanatory
|
||||||
|
@ -768,8 +768,8 @@ init_unix_addrinfo(rb_addrinfo_t *rai, VALUE path, int socktype)
|
|||||||
StringValue(path);
|
StringValue(path);
|
||||||
|
|
||||||
if (sizeof(un.sun_path) <= (size_t)RSTRING_LEN(path))
|
if (sizeof(un.sun_path) <= (size_t)RSTRING_LEN(path))
|
||||||
rb_raise(rb_eArgError, "too long unix socket path (max: %dbytes)",
|
rb_raise(rb_eArgError, "too long unix socket path (%ldbytes given but %dbytes max)",
|
||||||
(int)sizeof(un.sun_path)-1);
|
RSTRING_LEN(path), (int)sizeof(un.sun_path)-1);
|
||||||
|
|
||||||
MEMZERO(&un, struct sockaddr_un, 1);
|
MEMZERO(&un, struct sockaddr_un, 1);
|
||||||
|
|
||||||
|
@ -1429,8 +1429,8 @@ sock_s_pack_sockaddr_un(VALUE self, VALUE path)
|
|||||||
sockaddr.sun_family = AF_UNIX;
|
sockaddr.sun_family = AF_UNIX;
|
||||||
sun_path = StringValueCStr(path);
|
sun_path = StringValueCStr(path);
|
||||||
if (sizeof(sockaddr.sun_path) <= strlen(sun_path)) {
|
if (sizeof(sockaddr.sun_path) <= strlen(sun_path)) {
|
||||||
rb_raise(rb_eArgError, "too long unix socket path (max: %dbytes)",
|
rb_raise(rb_eArgError, "too long unix socket path (%ldbytes given but %dbytes max)",
|
||||||
(int)sizeof(sockaddr.sun_path)-1);
|
RSTRING_LEN(path), (int)sizeof(sockaddr.sun_path)-1);
|
||||||
}
|
}
|
||||||
strncpy(sockaddr.sun_path, sun_path, sizeof(sockaddr.sun_path)-1);
|
strncpy(sockaddr.sun_path, sun_path, sizeof(sockaddr.sun_path)-1);
|
||||||
addr = rb_str_new((char*)&sockaddr, sizeof(sockaddr));
|
addr = rb_str_new((char*)&sockaddr, sizeof(sockaddr));
|
||||||
|
@ -40,8 +40,8 @@ rsock_init_unixsock(VALUE sock, VALUE path, int server)
|
|||||||
MEMZERO(&sockaddr, struct sockaddr_un, 1);
|
MEMZERO(&sockaddr, struct sockaddr_un, 1);
|
||||||
sockaddr.sun_family = AF_UNIX;
|
sockaddr.sun_family = AF_UNIX;
|
||||||
if (sizeof(sockaddr.sun_path) <= (size_t)RSTRING_LEN(path)) {
|
if (sizeof(sockaddr.sun_path) <= (size_t)RSTRING_LEN(path)) {
|
||||||
rb_raise(rb_eArgError, "too long unix socket path (max: %dbytes)",
|
rb_raise(rb_eArgError, "too long unix socket path (%ldbytes given but %dbytes max)",
|
||||||
(int)sizeof(sockaddr.sun_path)-1);
|
RSTRING_LEN(path), (int)sizeof(sockaddr.sun_path)-1);
|
||||||
}
|
}
|
||||||
memcpy(sockaddr.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
|
memcpy(sockaddr.sun_path, RSTRING_PTR(path), RSTRING_LEN(path));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user