Date: Wed, 10 Aug 2005 15:08:06 GMT From: James Juran <James.Juran@baesystems.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/84761: shutdown() of non-connected socket should fail with ENOTCONN Message-ID: <200508101508.j7AF86od039907@www.freebsd.org> Resent-Message-ID: <200508101510.j7AFAHTI032439@freefall.freebsd.org>
index | next in thread | raw e-mail
>Number: 84761
>Category: kern
>Synopsis: shutdown() of non-connected socket should fail with ENOTCONN
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Wed Aug 10 15:10:17 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator: James Juran
>Release: 5.3-RELEASE
>Organization:
BAE Systems Inc.
>Environment:
FreeBSD bsdv6 5.3-RELEASE FreeBSD 5.3-RELEASE #0: Fri Nov 5 04:19:18 UTC 2004
root@harlow.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
>Description:
Calling shutdown(2) on a non-connected socket should fail with ENOTCONN
according to the manpage. Instead, it succeeds.
>How-To-Repeat:
Run this program. It should hit the perror(), but instead prints
"shutdown succeeded".
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
int main(void)
{
int s;
s = socket(PF_INET, SOCK_STREAM, 0);
if (s == -1)
{
perror("socket");
exit(1);
}
if (shutdown(s, SHUT_RD) == -1)
perror("shutdown");
else
printf("shutdown succeeded\n");
return 0;
}
>Fix:
Check for SS_ISCONNECTED in soshutdown, and return ENOTCONN if it
is not set.
>Release-Note:
>Audit-Trail:
>Unformatted:
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508101508.j7AF86od039907>
