diff options
author | Tobias Brunner <tobias@strongswan.org> | 2013-07-31 16:24:32 +0200 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2013-07-31 22:16:58 +0200 |
commit | 58e32e48711ab827bb504744029f95a0967e60db (patch) | |
tree | 7d59feaee4a69c3e264f74abb755856d3db5b4a1 | |
parent | 3a938a6f854a414df1a6dd9d8ef5761300b4623e (diff) | |
download | strongswan-5.1.0.tar.bz2 strongswan-5.1.0.tar.xz |
tnc-pdp: Initialize struct msghdr properly when reading RADIUS messages5.1.0
Before this e.g. msg_controllen was not initialized properly which could
cause invalid reads.
-rw-r--r-- | src/libcharon/plugins/tnc_pdp/tnc_pdp.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libcharon/plugins/tnc_pdp/tnc_pdp.c b/src/libcharon/plugins/tnc_pdp/tnc_pdp.c index 13914b968..a30d89535 100644 --- a/src/libcharon/plugins/tnc_pdp/tnc_pdp.c +++ b/src/libcharon/plugins/tnc_pdp/tnc_pdp.c @@ -456,22 +456,22 @@ static bool receive(private_tnc_pdp_t *this, int fd, watcher_event_t event) char buffer[MAX_PACKET]; int bytes_read = 0; host_t *source; - struct msghdr msg; - struct iovec iov; union { struct sockaddr_in in4; struct sockaddr_in6 in6; } src; + struct iovec iov = { + .iov_base = buffer, + .iov_len = MAX_PACKET, + }; + struct msghdr msg = { + .msg_name = &src, + .msg_namelen = sizeof(src), + .msg_iov = &iov, + .msg_iovlen = 1, + }; /* read received packet */ - msg.msg_name = &src; - msg.msg_namelen = sizeof(src); - iov.iov_base = buffer; - iov.iov_len = MAX_PACKET; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - msg.msg_flags = 0; - bytes_read = recvmsg(fd, &msg, 0); if (bytes_read < 0) { |