--- zzzz-none-000/linux-2.6.13.1/net/unix/af_unix.c 2005-09-10 02:42:58.000000000 +0000 +++ ohio-7170-487/linux-2.6.13.1/net/unix/af_unix.c 2007-08-17 12:10:39.000000000 +0000 @@ -177,7 +177,7 @@ * - if started by not zero, should be NULL terminated (FS object) * - if started by zero, it is abstract name. */ - + static int unix_mkname(struct sockaddr_un * sunaddr, int len, unsigned *hashp) { if (len <= sizeof(short) || len > sizeof(*sunaddr)) @@ -414,7 +414,7 @@ */ if (atomic_read(&unix_tot_inflight)) - unix_gc(); /* Garbage collect fds */ + unix_gc(); /* Garbage collect fds */ return 0; } @@ -671,7 +671,7 @@ struct sock *u; struct nameidata nd; int err = 0; - + if (sunname->sun_path[0]) { err = path_lookup(sunname->sun_path, LOOKUP_FOLLOW, &nd); if (err) @@ -1385,7 +1385,7 @@ return err; } - + static int unix_stream_sendmsg(struct kiocb *kiocb, struct socket *sock, struct msghdr *msg, size_t len) { @@ -1437,11 +1437,11 @@ if (size > SKB_MAX_ALLOC) size = SKB_MAX_ALLOC; - + /* * Grab a buffer */ - + skb=sock_alloc_send_skb(sk,size,msg->msg_flags&MSG_DONTWAIT, &err); if (skb==NULL) @@ -1503,7 +1503,7 @@ { int err; struct sock *sk = sock->sk; - + err = sock_error(sk); if (err) return err; @@ -1516,7 +1516,7 @@ return unix_dgram_sendmsg(kiocb, sock, msg, len); } - + static void unix_copy_addr(struct msghdr *msg, struct sock *sk) { struct unix_sock *u = unix_sk(sk); @@ -1539,6 +1539,7 @@ int noblock = flags & MSG_DONTWAIT; struct sk_buff *skb; int err; + int copied; err = -EOPNOTSUPP; if (flags&MSG_OOB) @@ -1557,12 +1558,16 @@ if (msg->msg_name) unix_copy_addr(msg, skb->sk); - if (size > skb->len) - size = skb->len; - else if (size < skb->len) + copied = skb->len; + if (copied > size) + { + copied = size; msg->msg_flags |= MSG_TRUNC; + } + if (copied < size) + copied = skb->len; - err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, size); + err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); if (err) goto out_free; @@ -1577,7 +1582,7 @@ if (UNIXCB(skb).fp) unix_detach_fds(siocb->scm, skb); } - else + else { /* It is questionable: on PEEK we could: - do not return fds - good, but too simple 8) @@ -1585,16 +1590,16 @@ apparently wrong) - clone fds (I chose it for now, it is the most universal solution) - + POSIX 1003.1g does not actually define this clearly at all. POSIX 1003.1g doesn't define a lot of things - clearly however! - + clearly however! + */ if (UNIXCB(skb).fp) siocb->scm->fp = scm_fp_dup(UNIXCB(skb).fp); } - err = size; + err = (flags & MSG_TRUNC) ? skb->len : copied; scm_recv(sock, msg, siocb->scm, flags); @@ -1609,7 +1614,7 @@ /* * Sleep until data has arrive. But check for races.. */ - + static long unix_stream_data_wait(struct sock * sk, long timeo) { DEFINE_WAIT(wait); @@ -1693,7 +1698,7 @@ /* * POSIX 1003.1g mandates this order. */ - + if ((err = sock_error(sk)) != 0) break; if (sk->sk_shutdown & RCV_SHUTDOWN) @@ -1907,7 +1912,7 @@ struct sock *s; for (s = first_unix_socket(iter); s; s = next_unix_socket(iter, s)) { - if (off == pos) + if (off == pos) return s; ++off; } @@ -1925,7 +1930,7 @@ { ++*pos; - if (v == (void *)1) + if (v == (void *)1) return first_unix_socket(seq->private); return next_unix_socket(seq->private, v); } @@ -1937,7 +1942,7 @@ static int unix_seq_show(struct seq_file *seq, void *v) { - + if (v == (void *)1) seq_puts(seq, "Num RefCount Protocol Flags Type St " "Inode Path\n"); @@ -2064,7 +2069,9 @@ { sock_unregister(PF_UNIX); unix_sysctl_unregister(); +#if defined(CONFIG_PROC_FS) proc_net_remove("unix"); +#endif /*--- #if defined(CONFIG_PROC_FS) ---*/ proto_unregister(&unix_proto); }