From owner-freebsd-standards@FreeBSD.ORG Tue Feb 23 14:30:02 2010 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 194C5106568D for ; Tue, 23 Feb 2010 14:30:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id D00718FC12 for ; Tue, 23 Feb 2010 14:30:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id o1NEU1Kx093188 for ; Tue, 23 Feb 2010 14:30:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id o1NEU1sq093182; Tue, 23 Feb 2010 14:30:01 GMT (envelope-from gnats) Resent-Date: Tue, 23 Feb 2010 14:30:01 GMT Resent-Message-Id: <201002231430.o1NEU1sq093182@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-standards@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Axel Dörfler Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3F22B106566C for ; Tue, 23 Feb 2010 14:25:04 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 2E1498FC12 for ; Tue, 23 Feb 2010 14:25:04 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o1NEP3ab077939 for ; Tue, 23 Feb 2010 14:25:03 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o1NEP3wQ077938; Tue, 23 Feb 2010 14:25:03 GMT (envelope-from nobody) Message-Id: <201002231425.o1NEP3wQ077938@www.freebsd.org> Date: Tue, 23 Feb 2010 14:25:03 GMT From: Axel Dörfler To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: standards/144231: bind/connect/sendto too strict about sockaddr length X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Feb 2010 14:30:02 -0000 >Number: 144231 >Category: standards >Synopsis: bind/connect/sendto too strict about sockaddr length >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Feb 23 14:30:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Axel Dörfler >Release: 8.0-RELEASE >Organization: >Environment: i386 >Description: bind(), connect(), and sendto() all have a socklen_t argument specifying the size of the sockaddr buffer passed in. However, with IPv4 at least, passing any other value than 16 (sizeof(sockaddr)) will result in EINVAL. There is no reason why this restriction is there, and it's quite unhandy when dealing with the sockaddr_storage structure. (I have not compiled the test program, but it should be able to reproduce the problem) >How-To-Repeat: #include #include #include int main() { sockaddr_storage buffer; ((sockaddr_in*)&buffer)->sa_family = AF_INET; ((sockaddr_in*)&buffer)->sa_addr.s_addr = INADDR_ANY; ((sockaddr_in*)&buffer)->sa_port = 0; int fd = socket(AF_INET, SOCK_DGRAM, 0); if (bind(fd, &buffer, sizeof(buffer)) != 0) perror("bind"); return 0; } >Fix: >Release-Note: >Audit-Trail: >Unformatted: