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

* ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno

before calling rb_sys_fail_str to prevent [BUG] errno == 0.
  Patch by Eric Wong. [ruby-core:59498] [Bug #9352]

* ext/socket/socket.c (rsock_sys_fail_path): ditto
* ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto
* ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto
* ext/socket/socket.c (rsock_sys_fail_raddrinfo_or_sockaddr): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
charliesome 2014-01-03 10:12:38 +00:00
parent 12b0986405
commit 8f04556111
2 changed files with 24 additions and 0 deletions

View file

@ -1,3 +1,14 @@
Fri Jan 3 19:09:00 2014 Eric Wong <normalperson@yhbt.net>
* ext/socket/socket.c (rsock_sys_fail_host_port): save and restore errno
before calling rb_sys_fail_str to prevent [BUG] errno == 0.
Patch by Eric Wong. [ruby-core:59498] [Bug #9352]
* ext/socket/socket.c (rsock_sys_fail_path): ditto
* ext/socket/socket.c (rsock_sys_fail_sockaddr): ditto
* ext/socket/socket.c (rsock_sys_fail_raddrinfo): ditto
* ext/socket/socket.c (rsock_sys_fail_raddrinfo_or_sockaddr): ditto
Fri Jan 3 10:43:57 2014 Aman Gupta <ruby@tmm1.net>
* test/net/imap/cacert.pem: generate new CA cert, since the last one

View file

@ -16,12 +16,14 @@ void
rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port)
{
VALUE message;
int err = errno;
port = rb_String(port);
message = rb_sprintf("%s for \"%s\" port %s",
mesg, StringValueCStr(host), StringValueCStr(port));
errno = err;
rb_sys_fail_str(message);
}
@ -29,6 +31,8 @@ void
rsock_sys_fail_path(const char *mesg, VALUE path)
{
VALUE message;
int err = errno;
if (RB_TYPE_P(path, T_STRING)) {
if (memchr(RSTRING_PTR(path), '\0', RSTRING_LEN(path))) {
path = rb_str_inspect(path);
@ -39,6 +43,7 @@ rsock_sys_fail_path(const char *mesg, VALUE path)
message = rb_sprintf("%s for \"%s\"", mesg,
StringValueCStr(path));
}
errno = err;
rb_sys_fail_str(message);
}
else {
@ -50,9 +55,11 @@ void
rsock_sys_fail_sockaddr(const char *mesg, struct sockaddr *addr, socklen_t len)
{
VALUE rai;
int err = errno;
rai = rsock_addrinfo_new(addr, len, PF_UNSPEC, 0, 0, Qnil, Qnil);
errno = err;
rsock_sys_fail_raddrinfo(mesg, rai);
}
@ -60,18 +67,24 @@ void
rsock_sys_fail_raddrinfo(const char *mesg, VALUE rai)
{
VALUE str, message;
int err = errno;
str = rsock_addrinfo_inspect_sockaddr(rai);
message = rb_sprintf("%s for %s", mesg, StringValueCStr(str));
errno = err;
rb_sys_fail_str(message);
}
void
rsock_sys_fail_raddrinfo_or_sockaddr(const char *mesg, VALUE addr, VALUE rai)
{
int err = errno;
if (NIL_P(rai)) {
StringValue(addr);
errno = err;
rsock_sys_fail_sockaddr(mesg,
(struct sockaddr *)RSTRING_PTR(addr),
(socklen_t)RSTRING_LEN(addr)); /* overflow should be checked already */