diff options
author | 2008-10-02 14:40:22 +0000 | |
---|---|---|
committer | 2008-10-02 14:40:22 +0000 | |
commit | 57c3de9ce21a7873609d9e77bbd2f44df3871367 (patch) | |
tree | b046981da3f581af1fa0d946aa8e9d372cb2fffb /sys/kern/sys_socket.c | |
parent | Convert an unchecked strdup to xstrdup. OK deraadt@ (diff) | |
download | wireguard-openbsd-57c3de9ce21a7873609d9e77bbd2f44df3871367.tar.xz wireguard-openbsd-57c3de9ce21a7873609d9e77bbd2f44df3871367.zip |
A closed, disconnected, or otherwise failed socket is still a socket
and should return stat information instead of EINVAL from deep in the
guts of tcp_usrreq. While there, put some more information into struct
stat, inspired by FreeBSD. EINVAL problem reported in PR 5943
Diffstat (limited to 'sys/kern/sys_socket.c')
-rw-r--r-- | sys/kern/sys_socket.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/sys_socket.c b/sys/kern/sys_socket.c index 9ebffb76bc8..3665003969b 100644 --- a/sys/kern/sys_socket.c +++ b/sys/kern/sys_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_socket.c,v 1.12 2008/05/23 15:51:12 thib Exp $ */ +/* $OpenBSD: sys_socket.c,v 1.13 2008/10/02 14:40:22 deraadt Exp $ */ /* $NetBSD: sys_socket.c,v 1.13 1995/08/12 23:59:09 mycroft Exp $ */ /* @@ -167,9 +167,17 @@ soo_stat(struct file *fp, struct stat *ub, struct proc *p) bzero((caddr_t)ub, sizeof (*ub)); ub->st_mode = S_IFSOCK; - return ((*so->so_proto->pr_usrreq)(so, PRU_SENSE, + if ((so->so_state & SS_CANTRCVMORE) == 0 || + so->so_rcv.sb_cc != 0) + ub->st_mode |= S_IRUSR | S_IRGRP | S_IROTH; + if ((so->so_state & SS_CANTSENDMORE) == 0) + ub->st_mode |= S_IWUSR | S_IWGRP | S_IWOTH; + ub->st_uid = so->so_euid; + ub->st_gid = so->so_egid; + (void) ((*so->so_proto->pr_usrreq)(so, PRU_SENSE, (struct mbuf *)ub, (struct mbuf *)0, (struct mbuf *)0, p)); + return (0); } /* ARGSUSED */ |