diff options
-rw-r--r-- | lib/libc/sys/dup.2 | 17 | ||||
-rw-r--r-- | lib/libc/sys/fcntl.2 | 2 | ||||
-rw-r--r-- | sys/kern/kern_descrip.c | 2 |
3 files changed, 13 insertions, 8 deletions
diff --git a/lib/libc/sys/dup.2 b/lib/libc/sys/dup.2 index f6f6f46..d2a4b7e 100644 --- a/lib/libc/sys/dup.2 +++ b/lib/libc/sys/dup.2 @@ -128,20 +128,27 @@ indicates the cause of the error. .Sh ERRORS The .Fn dup -and -.Fn dup2 -system calls fail if: +system call fails if: .Bl -tag -width Er .It Bq Er EBADF The .Fa oldd -or -.Fa newd argument is not a valid active descriptor .It Bq Er EMFILE Too many descriptors are active. .El +The +.Fn dup2 +system call fails if: +.Bl -tag -width Er +.It Bq Er EBADF +The +.Fa oldd +argument is not a valid active descriptor or the +.Fa newd +argument is negative or exceeds the maximum allowable descriptor number +.El .Sh SEE ALSO .Xr accept 2 , .Xr cap_new 2 , diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2 index 4f6c155..beceb72 100644 --- a/lib/libc/sys/fcntl.2 +++ b/lib/libc/sys/fcntl.2 @@ -539,8 +539,6 @@ The argument .Fa cmd is .Dv F_DUPFD -or -.Dv F_DUP2FD and the maximum number of file descriptors permitted for the process are already in use, or no file descriptors greater than or equal to diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 251a558..76c5db2 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -817,7 +817,7 @@ do_dup(struct thread *td, int flags, int old, int new, maxfd = min((int)lim_cur(p, RLIMIT_NOFILE), maxfilesperproc); PROC_UNLOCK(p); if (new >= maxfd) - return (flags & DUP_FCNTL ? EINVAL : EMFILE); + return (flags & DUP_FCNTL ? EINVAL : EBADF); FILEDESC_XLOCK(fdp); if (old >= fdp->fd_nfiles || fdp->fd_ofiles[old] == NULL) { |