lkml.org 
[lkml]   [1998]   [Aug]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Linux recvfrom() broken (was: DNS problems)
Date
From
> Linux 2.0 returns the number of bytes removed from the queue not the
> number copied. It doesn't overrun the buffer.

From 2.1.115 net/ipv4/udp.c udp_recvmsg():
skb = skb_recv_datagram(sk, flags, noblock, &err);
if (!skb)
goto out;

copied = skb->len - sizeof(struct udphdr);
if (copied > len)
{
copied = len;
msg->msg_flags |= MSG_TRUNC;
}
/*...*/
err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), msg->msg_iov,
copied);
if (err)
goto out_free;
/*...*/
if (sk->ip_cmsg_flags)
ip_cmsg_recv(msg, skb);
err = copied;

out_free:
skb_free_datagram(sk, skb);
out:
return err;


As I read this, the amount copied is limited to the size of the user
buffer (of course), and the number returned _is_ the amount copied.
As I needed it for another purpose, I've just compared this routine
with the one in 2.0.35 line by line and the only change was the
MSG_TRUNC setting, which 2.0.35 doesn't have.

How can the above code possibly return a value greater than "len"?

olaf


-
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.altern.org/andrebalsa/doc/lkml-faq.html

\
 
 \ /
  Last update: 2005-03-22 13:44    [W:0.035 / U:2.648 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site