aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ext/socket/socket.c13
2 files changed, 15 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 2af3ffd7b2..d538a10f39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Apr 6 11:49:35 2013 Tanaka Akira <akr@fsij.org>
+
+ * ext/socket/socket.c (rsock_sys_fail_path): Use rb_str_inspect if the
+ path contains a NUL.
+
Sat Apr 6 11:39:19 2013 Tanaka Akira <akr@fsij.org>
* ext/socket: Improve socket exception message to show socket address.
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 10412be719..be7bd62236 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);
}