diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-02-15 20:00:51 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-02-15 20:00:51 +0000 |
commit | b0054dff6dd118432f691e33d7f394a3256ac6fe (patch) | |
tree | bbeb4baf91ce41d8a7923f782d67f9f6a0b73a13 /sys/kern | |
parent | 94281ab221cb786c1cdcfceff6127e6c63956419 (diff) |
use socklen_t
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/syscalls.master | 18 | ||||
-rw-r--r-- | sys/kern/uipc_syscalls.c | 69 |
2 files changed, 41 insertions, 46 deletions
diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index c679ebefcce..9bf47b2760a 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -1,4 +1,4 @@ -; $OpenBSD: syscalls.master,v 1.32 1998/11/18 01:14:25 art Exp $ +; $OpenBSD: syscalls.master,v 1.33 1999/02/15 20:00:49 millert Exp $ ; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -89,13 +89,13 @@ const struct msghdr *msg, int flags); } 29 STD { ssize_t sys_recvfrom(int s, void *buf, size_t len, \ int flags, struct sockaddr *from, \ - int *fromlenaddr); } + socklen_t *fromlenaddr); } 30 STD { int sys_accept(int s, struct sockaddr *name, \ - int *anamelen); } + socklen_t *anamelen); } 31 STD { int sys_getpeername(int fdes, struct sockaddr *asa, \ int *alen); } 32 STD { int sys_getsockname(int fdes, struct sockaddr *asa, \ - int *alen); } + socklen_t *alen); } 33 STD { int sys_access(const char *path, int flags); } 34 STD { int sys_chflags(const char *path, u_int flags); } 35 STD { int sys_fchflags(int fd, u_int flags); } @@ -190,7 +190,7 @@ 96 STD { int sys_setpriority(int which, int who, int prio); } 97 STD { int sys_socket(int domain, int type, int protocol); } 98 STD { int sys_connect(int s, const struct sockaddr *name, \ - int namelen); } + socklen_t namelen); } 99 COMPAT_43 { int sys_accept(int s, caddr_t name, \ int *anamelen); } oaccept 100 STD { int sys_getpriority(int which, int who); } @@ -200,9 +200,9 @@ int flags); } orecv 103 STD { int sys_sigreturn(struct sigcontext *sigcntxp); } 104 STD { int sys_bind(int s, const struct sockaddr *name, \ - int namelen); } + socklen_t namelen); } 105 STD { int sys_setsockopt(int s, int level, int name, \ - const void *val, int valsize); } + const void *val, socklen_t valsize); } 106 STD { int sys_listen(int s, int backlog); } 107 OBSOL vtimes 108 COMPAT_43 { int sys_sigvec(int signum, struct sigvec *nsv, \ @@ -225,7 +225,7 @@ struct timezone *tzp); } 117 STD { int sys_getrusage(int who, struct rusage *rusage); } 118 STD { int sys_getsockopt(int s, int level, int name, \ - void *val, int *avalsize); } + void *val, socklen_t *avalsize); } 119 OBSOL resuba 120 STD { ssize_t sys_readv(int fd, \ const struct iovec *iovp, int iovcnt); } @@ -260,7 +260,7 @@ 140 STD { int sys_adjtime(const struct timeval *delta, \ struct timeval *olddelta); } 141 COMPAT_43 { int sys_getpeername(int fdes, caddr_t asa, \ - int *alen); } ogetpeername + socklen_t *alen); } ogetpeername 142 COMPAT_43 { int32_t sys_gethostid(void); } ogethostid 143 COMPAT_43 { int sys_sethostid(int32_t hostid); } osethostid 144 COMPAT_43 { int sys_getrlimit(int which, \ diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 39b89b18242..746d7275754 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.17 1999/02/14 21:11:01 millert Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.18 1999/02/15 20:00:50 millert Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -104,7 +104,7 @@ sys_bind(p, v, retval) register struct sys_bind_args /* { syscallarg(int) s; syscallarg(struct sockaddr *) name; - syscallarg(int) namelen; + syscallarg(socklen_t) namelen; } */ *uap = v; struct file *fp; struct mbuf *nam; @@ -149,20 +149,17 @@ sys_accept(p, v, retval) register struct sys_accept_args /* { syscallarg(int) s; syscallarg(struct sockaddr *) name; - syscallarg(int *) anamelen; + syscallarg(socklen_t *) anamelen; } */ *uap = v; struct file *fp; struct mbuf *nam; - int namelen, error, s, tmpfd; + socklen_t namelen; + int error, s, tmpfd; register struct socket *so; - if (SCARG(uap, name)) { - if ((error = copyin((caddr_t)SCARG(uap, anamelen), - (caddr_t)&namelen, sizeof (namelen)))) - return (error); - if (namelen < 0) - return (EFAULT); - } + if (SCARG(uap, name) && (error = copyin((caddr_t)SCARG(uap, anamelen), + (caddr_t)&namelen, sizeof (namelen)))) + return (error); if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) return (error); s = splsoftnet(); @@ -214,7 +211,7 @@ sys_accept(p, v, retval) namelen = nam->m_len; /* SHOULD COPY OUT A CHAIN HERE */ if ((error = copyout(mtod(nam, caddr_t), - (caddr_t)SCARG(uap, name), (u_int)namelen)) == 0) + (caddr_t)SCARG(uap, name), namelen)) == 0) error = copyout((caddr_t)&namelen, (caddr_t)SCARG(uap, anamelen), sizeof (*SCARG(uap, anamelen))); @@ -234,7 +231,7 @@ sys_connect(p, v, retval) register struct sys_connect_args /* { syscallarg(int) s; syscallarg(struct sockaddr *) name; - syscallarg(int) namelen; + syscallarg(socklen_t) namelen; } */ *uap = v; struct file *fp; register struct socket *so; @@ -529,7 +526,7 @@ sys_recvfrom(p, v, retval) syscallarg(size_t) len; syscallarg(int) flags; syscallarg(struct sockaddr *) from; - syscallarg(int *) fromlenaddr; + syscallarg(socklen_t *) fromlenaddr; } */ *uap = v; struct msghdr msg; struct iovec aiov; @@ -614,7 +611,8 @@ recvit(p, s, mp, namelenp, retsize) struct uio auio; register struct iovec *iov; register int i; - int len, error; + size_t len; + int error; struct mbuf *from = 0, *control = 0; #ifdef KTRACE struct iovec *ktriov = NULL; @@ -767,7 +765,7 @@ sys_setsockopt(p, v, retval) syscallarg(int) level; syscallarg(int) name; syscallarg(caddr_t) val; - syscallarg(int) valsize; + syscallarg(socklen_t) valsize; } */ *uap = v; struct file *fp; struct mbuf *m = NULL; @@ -782,7 +780,7 @@ sys_setsockopt(p, v, retval) if (m == NULL) return (ENOBUFS); error = copyin(SCARG(uap, val), mtod(m, caddr_t), - (u_int)SCARG(uap, valsize)); + SCARG(uap, valsize)); if (error) { (void) m_free(m); return (error); @@ -805,11 +803,12 @@ sys_getsockopt(p, v, retval) syscallarg(int) level; syscallarg(int) name; syscallarg(caddr_t) val; - syscallarg(int *) avalsize; + syscallarg(socklen_t *) avalsize; } */ *uap = v; struct file *fp; struct mbuf *m = NULL; - int valsize, error; + socklen_t valsize; + int error; if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) return (error); @@ -820,15 +819,12 @@ sys_getsockopt(p, v, retval) return (error); } else valsize = 0; - if (valsize < 0) - return (EFAULT); if ((error = sogetopt((struct socket *)fp->f_data, SCARG(uap, level), SCARG(uap, name), &m)) == 0 && SCARG(uap, val) && valsize && m != NULL) { if (valsize > m->m_len) valsize = m->m_len; - error = copyout(mtod(m, caddr_t), SCARG(uap, val), - (u_int)valsize); + error = copyout(mtod(m, caddr_t), SCARG(uap, val), valsize); if (error == 0) error = copyout((caddr_t)&valsize, (caddr_t)SCARG(uap, avalsize), sizeof (valsize)); @@ -899,20 +895,19 @@ sys_getsockname(p, v, retval) register struct sys_getsockname_args /* { syscallarg(int) fdes; syscallarg(caddr_t) asa; - syscallarg(int *) alen; + syscallarg(socklen_t *) alen; } */ *uap = v; struct file *fp; register struct socket *so; struct mbuf *m; - int len, error; + socklen_t len; + int error; if ((error = getsock(p->p_fd, SCARG(uap, fdes), &fp)) != 0) return (error); error = copyin((caddr_t)SCARG(uap, alen), (caddr_t)&len, sizeof (len)); if (error) return (error); - if (len < 0) - return (EFAULT); so = (struct socket *)fp->f_data; m = m_getclr(M_WAIT, MT_SONAME); if (m == NULL) @@ -922,7 +917,7 @@ sys_getsockname(p, v, retval) goto bad; if (len > m->m_len) len = m->m_len; - error = copyout(mtod(m, caddr_t), (caddr_t)SCARG(uap, asa), (u_int)len); + error = copyout(mtod(m, caddr_t), (caddr_t)SCARG(uap, asa), len); if (error == 0) error = copyout((caddr_t)&len, (caddr_t)SCARG(uap, alen), sizeof (len)); @@ -944,12 +939,13 @@ sys_getpeername(p, v, retval) register struct sys_getpeername_args /* { syscallarg(int) fdes; syscallarg(caddr_t) asa; - syscallarg(int *) alen; + syscallarg(socklen_t *) alen; } */ *uap = v; struct file *fp; register struct socket *so; struct mbuf *m; - int len, error; + socklen_t len; + int error; if ((error = getsock(p->p_fd, SCARG(uap, fdes), &fp)) != 0) return (error); @@ -959,8 +955,6 @@ sys_getpeername(p, v, retval) error = copyin((caddr_t)SCARG(uap, alen), (caddr_t)&len, sizeof (len)); if (error) return (error); - if (len < 0) - return (EFAULT); m = m_getclr(M_WAIT, MT_SONAME); if (m == NULL) return (ENOBUFS); @@ -969,7 +963,7 @@ sys_getpeername(p, v, retval) goto bad; if (len > m->m_len) len = m->m_len; - error = copyout(mtod(m, caddr_t), (caddr_t)SCARG(uap, asa), (u_int)len); + error = copyout(mtod(m, caddr_t), (caddr_t)SCARG(uap, asa), len); if (error == 0) error = copyout((caddr_t)&len, (caddr_t)SCARG(uap, alen), sizeof (len)); @@ -982,15 +976,16 @@ int sockargs(mp, buf, buflen, type) struct mbuf **mp; caddr_t buf; - int buflen, type; + socklen_t buflen; + int type; { register struct sockaddr *sa; register struct mbuf *m; int error; - if ((u_int)buflen > MLEN) { + if (buflen > MLEN) { #ifdef COMPAT_OLDSOCK - if (type == MT_SONAME && (u_int)buflen <= 112) + if (type == MT_SONAME && buflen <= 112) buflen = MLEN; /* unix domain compat. hack */ else #endif @@ -1000,7 +995,7 @@ sockargs(mp, buf, buflen, type) if (m == NULL) return (ENOBUFS); m->m_len = buflen; - error = copyin(buf, mtod(m, caddr_t), (u_int)buflen); + error = copyin(buf, mtod(m, caddr_t), buflen); if (error) { (void) m_free(m); return (error); |