Messages in this thread Patch in this message | | | Subject | tcp/udp recvfrom does not set address if return == 0 | From | Assar Westerlund <> | Date | 05 Jul 1999 21:36:57 +0200 |
| |
If you're doing recvfrom(socket, buf, len, flags, from, from_len) and the return value is zero, from_len gets set but the address isn't copied into from.
The following patch only sets from_len if the address is also copied to from and (for the TCP-case) also does it return value == 0.
/assar
--- net/ipv4/tcp.c.orig Mon Jul 5 20:57:57 1999 +++ net/ipv4/tcp.c Mon Jul 5 20:58:16 1999 @@ -1306,12 +1306,12 @@ break; } - if(copied > 0 && msg->msg_name) + if(copied >= 0 && msg->msg_name) { tp->af_specific->addr2sockaddr(sk, (struct sockaddr *) msg->msg_name); - if(addr_len) *addr_len = tp->af_specific->sockaddr_len; + } remove_wait_queue(sk->sleep, &wait); current->state = TASK_RUNNING; --- net/ipv4/udp.c.orig Mon Jul 5 20:57:59 1999 +++ net/ipv4/udp.c Mon Jul 5 20:59:08 1999 @@ -862,12 +862,6 @@ struct sk_buff *skb; int copied, err; - /* - * Check any passed addresses - */ - if (addr_len) - *addr_len=sizeof(*sin); - if (flags & MSG_ERRQUEUE) return ip_recv_error(sk, msg, len); @@ -918,6 +912,12 @@ /* Copy the address. */ if (sin) { + /* + * Check any passed addresses + */ + if (addr_len) + *addr_len=sizeof(*sin); + sin->sin_family = AF_INET; sin->sin_port = skb->h.uh->source; sin->sin_addr.s_addr = skb->nh.iph->saddr; - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |