From owner-freebsd-current@FreeBSD.ORG Wed Feb 20 17:19:24 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 42D58291 for ; Wed, 20 Feb 2013 17:19:24 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by mx1.freebsd.org (Postfix) with ESMTP id D75AC2F7 for ; Wed, 20 Feb 2013 17:19:23 +0000 (UTC) Received: by mail-wi0-f181.google.com with SMTP id hm6so6524893wib.8 for ; Wed, 20 Feb 2013 09:19:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=5GztlotZxvRZoEk+EiY8GXyfrv2UL9kjA+Dhxbrmsb8=; b=wO6A4qAwQVKMC2MWOPQdL6BUxTA0VVzT9W7CtYnlHcVLEVVmHTMXclc4xuBrXhWCYj ZhN/JEGgv5E6AOB8sxh7djthPSmYe4AOkFgr4lqYPDOyJtFV7VJ4oVhhoVIsak+akEfr rcsbXgbzzTK6njdfmfRmiDRjt6ZUcHbwPEPGC8nxmu7Xjf+LW52ZRG/YXHi35hGlApkl mJubnpiHgQo54JxqNTyiEJc4Fm8my6xslJfmcZyObiAruWKs4E6yEsIv2uQN9aFhnJMV 8OjGy9e48TRi5/OquYPRpkwBXaeyHV0qm5HZnQOZySoeRl0S46SyU1PPKpBr58nOmRMk YcGA== MIME-Version: 1.0 X-Received: by 10.194.242.69 with SMTP id wo5mr35477115wjc.10.1361380757603; Wed, 20 Feb 2013 09:19:17 -0800 (PST) Received: by 10.194.86.167 with HTTP; Wed, 20 Feb 2013 09:19:17 -0800 (PST) Date: Wed, 20 Feb 2013 20:19:17 +0300 Message-ID: Subject: [patch] remove negative socklen_t checks From: Sergey Kandaurov To: FreeBSD Current Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2013 17:19:24 -0000 Hi. These checks are useless after the address length argument is converted to socklen_t (up to SUSv2). Any objections? Index: lib/libc/sys/accept.2 =================================================================== --- lib/libc/sys/accept.2 (revision 245745) +++ lib/libc/sys/accept.2 (working copy) @@ -28,7 +28,7 @@ .\" @(#)accept.2 8.2 (Berkeley) 12/11/93 .\" $FreeBSD$ .\" -.Dd December 11, 1993 +.Dd February 20, 2013 .Dt ACCEPT 2 .Os .Sh NAME @@ -154,10 +154,6 @@ The descriptor references a file, not a socket. .It Bq Er EINVAL .Xr listen 2 has not been called on the socket descriptor. -.It Bq Er EINVAL -The -.Fa addrlen -argument is negative. .It Bq Er EFAULT The .Fa addr Index: sys/kern/uipc_syscalls.c =================================================================== --- sys/kern/uipc_syscalls.c (revision 246354) +++ sys/kern/uipc_syscalls.c (working copy) @@ -353,8 +353,6 @@ kern_accept(struct thread *td, int s, struct socka if (name) { *name = NULL; - if (*namelen < 0) - return (EINVAL); } AUDIT_ARG_FD(s); @@ -1327,8 +1325,6 @@ kern_setsockopt(td, s, level, name, val, valseg, v if (val == NULL && valsize != 0) return (EFAULT); - if ((int)valsize < 0) - return (EINVAL); sopt.sopt_dir = SOPT_SET; sopt.sopt_level = level; @@ -1406,8 +1402,6 @@ kern_getsockopt(td, s, level, name, val, valseg, v if (val == NULL) *valsize = 0; - if ((int)*valsize < 0) - return (EINVAL); sopt.sopt_dir = SOPT_GET; sopt.sopt_level = level; @@ -1484,9 +1478,6 @@ kern_getsockname(struct thread *td, int fd, struct socklen_t len; int error; - if (*alen < 0) - return (EINVAL); - AUDIT_ARG_FD(fd); error = getsock_cap(td->td_proc->p_fd, fd, CAP_GETSOCKNAME, &fp, NULL); if (error) @@ -1584,9 +1575,6 @@ kern_getpeername(struct thread *td, int fd, struct socklen_t len; int error; - if (*alen < 0) - return (EINVAL); - AUDIT_ARG_FD(fd); error = getsock_cap(td->td_proc->p_fd, fd, CAP_GETPEERNAME, &fp, NULL); if (error) -- wbr, pluknet