summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-06 02:50:08 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-06 02:50:08 +0000
commit11a9d772860d8123d9284ab11535fe6398742576 (patch)
tree24fce312bb47636bbe940b20d454e1982eea3a76 /ext/socket/socket.c
parentd933fb2296e4ace25c5eb558be56cd23a8fcc88f (diff)
* ext/socket/socket.c (rsock_sys_fail_path): Use rb_str_inspect if the
path contains a NUL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 10412be..be7bd62 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -28,9 +28,16 @@ rsock_sys_fail_host_port(const char *mesg, VALUE host, VALUE port)
void
rsock_sys_fail_path(const char *mesg, VALUE path)
{
- VALUE message = rb_sprintf("%s for \"%s\"",
- mesg, StringValueCStr(path));
-
+ VALUE message;
+ if (memchr(RSTRING_PTR(path), '\0', RSTRING_LEN(path))) {
+ path = rb_str_inspect(path);
+ message = rb_sprintf("%s for %s", mesg,
+ StringValueCStr(path));
+ }
+ else {
+ message = rb_sprintf("%s for \"%s\"", mesg,
+ StringValueCStr(path));
+ }
rb_sys_fail_str(message);
}