summaryrefslogtreecommitdiff
path: root/ext/socket/extconf.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-24 11:04:11 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-24 11:04:11 +0000
commit0283c3d0bba4f4fca5da128bb0544e5745778cb3 (patch)
tree7bb81787dc313fc68c4f21ec779f35a05ab5e3f6 /ext/socket/extconf.rb
parentf5b9de7502139b6c4013476e89b207fe39a5c104 (diff)
* ext/socket/extconf.rb: fix the recvmsg test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32656 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/socket/extconf.rb')
-rw-r--r--ext/socket/extconf.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb
index 741554d..f835449 100644
--- a/ext/socket/extconf.rb
+++ b/ext/socket/extconf.rb
@@ -147,7 +147,7 @@ int main(int argc, char *argv[])
} s_cmsg, r_cmsg;
struct iovec s_iov, r_iov;
char s_buf[1], r_buf[1];
- struct stat statbuf;
+ struct stat s_statbuf, r_statbuf;
s_fd = 0; /* stdin */
@@ -198,13 +198,23 @@ int main(int argc, char *argv[])
if (r_msg.msg_controllen < CMSG_LEN(sizeof(int))) exit(EXIT_FAILURE);
if (r_cmsg.hdr.cmsg_len < CMSG_LEN(sizeof(int))) exit(EXIT_FAILURE);
- memcpy((char *)&r_fd, CMSG_DATA(&s_cmsg.hdr), sizeof(int));
+ memcpy((char *)&r_fd, CMSG_DATA(&r_cmsg.hdr), sizeof(int));
if (r_fd < 0) exit(EXIT_FAILURE);
- ret = fstat(r_fd, &statbuf);
+ if (r_fd == s_fd) exit(EXIT_FAILURE);
+
+ ret = fstat(s_fd, &s_statbuf);
+ if (ret == -1) { exit(EXIT_FAILURE); }
+
+ ret = fstat(r_fd, &r_statbuf);
if (ret == -1) { exit(EXIT_FAILURE); }
+ if (s_statbuf.st_dev != r_statbuf.st_dev ||
+ s_statbuf.st_ino != r_statbuf.st_ino) {
+ exit(EXIT_FAILURE);
+ }
+
return EXIT_SUCCESS;
}
EOF