summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Griess <pg@std.in>2010-05-04 11:26:23 -0500
committerRyan Dahl <ry@tinyclouds.org>2010-05-04 10:32:01 -0700
commitd9882395e2ceb0274e15a3ba80df900d1e527c0d (patch)
tree6d308259fc006b8ee48d15e9c8be3cf24d405b57
parent1a317135c5d65fe519ad8fa335342272ea53ddbc (diff)
downloadnodejs-d9882395e2ceb0274e15a3ba80df900d1e527c0d.tar.gz
nodejs-d9882395e2ceb0274e15a3ba80df900d1e527c0d.tar.bz2
nodejs-d9882395e2ceb0274e15a3ba80df900d1e527c0d.zip
Fix SEGV by setting msg_controllen earlier.
- Some implementations of CMSG_FIRSTHDR() rely on msg_controllen being set correctly, else it returns NULL: see <linux/socket.h>.
-rw-r--r--src/node_net2.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/node_net2.cc b/src/node_net2.cc
index 2958e0323..865bf7c50 100644
--- a/src/node_net2.cc
+++ b/src/node_net2.cc
@@ -671,12 +671,12 @@ static Handle<Value> SendFD(const Arguments& args) {
msg.msg_namelen = 0;
msg.msg_flags = 0;
msg.msg_control = (void *) control_msg;
+ msg.msg_controllen = CMSG_LEN(sizeof(fd_to_send));
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
- cmsg->cmsg_len = CMSG_LEN(sizeof(fd_to_send));
+ cmsg->cmsg_len = msg.msg_controllen;
*(int*) CMSG_DATA(cmsg) = fd_to_send;
- msg.msg_controllen = cmsg->cmsg_len;
ssize_t written = sendmsg(fd, &msg, 0);