summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-09 00:06:41 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-09 00:06:41 +0000
commit70f76601969f7e8b5bfb3bfd5d83e5d32c5c3e41 (patch)
tree2f10a45f726b1bacde34c922de9908b0b7852650
parent64f12a46d591887a716822305dba29dd3da1cf8f (diff)
* ext/socket/option.c (inspect_local_peercred): check version.
(sockopt_inspect): suppress warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/socket/option.c6
2 files changed, 11 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 72c5ec1593..53dad3b76f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Mon Feb 9 09:05:12 2009 Tanaka Akira <akr@fsij.org>
+
+ * ext/socket/option.c (inspect_local_peercred): check version.
+ (sockopt_inspect): suppress warning.
+
Mon Feb 9 02:04:03 2009 Tanaka Akira <akr@fsij.org>
* ext/socket/option.c (inspect_peercred): struct ucred contains
diff --git a/ext/socket/option.c b/ext/socket/option.c
index 36750ad6c0..0b461f174a 100644
--- a/ext/socket/option.c
+++ b/ext/socket/option.c
@@ -263,6 +263,8 @@ inspect_local_peercred(int level, int optname, VALUE data, VALUE ret)
if (RSTRING_LEN(data) == sizeof(struct xucred)) {
struct xucred cred;
memcpy(&cred, RSTRING_PTR(data), sizeof(struct xucred));
+ if (cred.cr_version != XUCRED_VERSION)
+ return -1;
rb_str_catf(ret, " version=%u", cred.cr_version);
rb_str_catf(ret, " euid=%u", cred.cr_uid);
if (cred.cr_ngroups) {
@@ -330,6 +332,7 @@ sockopt_inspect(VALUE self)
if (optname == LOCAL_PEERCRED) {
if (inspect_local_peercred(level, optname, data, ret) == -1) goto dump;
goto finish;
+#define USE_FINISH 1
}
# endif
}
@@ -437,7 +440,10 @@ sockopt_inspect(VALUE self)
rb_str_catf(ret, " %s", StringValueCStr(data));
}
+#ifdef USE_FINISH
finish:
+#endif
+#undef USE_FINISH
rb_str_cat2(ret, ">");
return ret;