[patch] remove negative socklen_t checks

From: Sergey Kandaurov <pluknet_at_gmail.com>
Date: Wed, 20 Feb 2013 20:19:17 +0300
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)
_at__at_ -28,7 +28,7 _at__at_
 .\"     _at_(#)accept.2   8.2 (Berkeley) 12/11/93
 .\" $FreeBSD$
 .\"
-.Dd December 11, 1993
+.Dd February 20, 2013
 .Dt ACCEPT 2
 .Os
 .Sh NAME
_at__at_ -154,10 +154,6 _at__at_ 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)
_at__at_ -353,8 +353,6 _at__at_ kern_accept(struct thread *td, int s, struct socka

        if (name) {
                *name = NULL;
-               if (*namelen < 0)
-                       return (EINVAL);
        }

        AUDIT_ARG_FD(s);
_at__at_ -1327,8 +1325,6 _at__at_ 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;
_at__at_ -1406,8 +1402,6 _at__at_ 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;
_at__at_ -1484,9 +1478,6 _at__at_ 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)
_at__at_ -1584,9 +1575,6 _at__at_ 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
Received on Wed Feb 20 2013 - 16:19:24 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:35 UTC