Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Jan 1998 18:58:55 GMT
From:      njs3@doc.ic.ac.uk
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   kern/5611: bind does not check sockaddr.sin_family corresponds to socket type
Message-ID:  <199801311858.SAA00642@sprite65.doc.ic.ac.uk>

next in thread | raw e-mail | index | archive | help

>Number:         5611
>Category:       kern
>Synopsis:       bind does not check sockaddr->sin_family corresponds to socket type
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 31 11:10:00 PST 1998
>Last-Modified:
>Originator:     Niall Smart
>Organization:
>Release:        FreeBSD 3.0-971225-SNAP i386
>Environment:
>Description:

the bind() syscall does not check that the sin_family member of the
sockaddr passed is appropriate for the type of socket that the bind
is being applied to

>How-To-Repeat:

        struct sockaddr_in      sin;
	int			fd;

        if ( (fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
                perror("socket");
                exit(1);
        }

        bzero(&sin, sizeof(sin));

        sin.sin_port = htons(3456);
        sin.sin_family = AF_UNIX;
        sin.sin_addr.s_addr = htonl(INADDR_ANY);

        if (bind(fd, (struct sockaddr*) &sin, sizeof(sin)) < 0) {
                perror("bind");
                exit(1);
        }

The above code executes successfully, however bind should return -1
because sin.sin_family is AF_UNIX, not AF_INET.

>Fix:
	
	

>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199801311858.SAA00642>