kern/84761: shutdown() of non-connected socket should fail with ENOTCONN

James Juran James.Juran at baesystems.com
Wed Aug 10 15:10:19 GMT 2005


>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 at 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:


More information about the freebsd-bugs mailing list