]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
[IPV4/IPV6]: Setting 0 for unused port field in RAW IP recvmsg().
authorTetsuo Handa <from-linux-kernel@i-love.sakura.ne.jp>
Wed, 26 Jul 2006 00:05:35 +0000 (17:05 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Jul 2006 00:05:35 +0000 (17:05 -0700)
From: Tetsuo Handa from-linux-kernel@i-love.sakura.ne.jp

The recvmsg() for raw socket seems to return random u16 value
from the kernel stack memory since port field is not initialized.
But I'm not sure this patch is correct.
Does raw socket return any information stored in port field?

[ BSD defines RAW IP recvmsg to return a sin_port value of zero.
  This is described in Steven's TCP/IP Illustrated Volume 2 on
  page 1055, which is discussing the BSD rip_input() implementation. ]

Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/raw.c
net/ipv6/raw.c

index bd221ec3f81eb668390d9e811712c8bc3da6fdfd..62b2762a2420bb1331d88d0d076737c1cc358ac3 100644 (file)
@@ -609,6 +609,7 @@ static int raw_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
        if (sin) {
                sin->sin_family = AF_INET;
                sin->sin_addr.s_addr = skb->nh.iph->saddr;
+               sin->sin_port = 0;
                memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
        }
        if (inet->cmsg_flags)
index fa1ce0ae123ed0d855d9db3cfb44c380cb668058..d57e61ce4a7db05f776d58f546d8d3c2d0a865ef 100644 (file)
@@ -411,6 +411,7 @@ static int rawv6_recvmsg(struct kiocb *iocb, struct sock *sk,
        /* Copy the address. */
        if (sin6) {
                sin6->sin6_family = AF_INET6;
+               sin6->sin6_port = 0;
                ipv6_addr_copy(&sin6->sin6_addr, &skb->nh.ipv6h->saddr);
                sin6->sin6_flowinfo = 0;
                sin6->sin6_scope_id = 0;