svn commit: r235125 - stable/9/sys/kern

Eitan Adler eadler at FreeBSD.org
Mon May 7 12:19:50 UTC 2012


Author: eadler
Date: Mon May  7 12:19:49 2012
New Revision: 235125
URL: http://svn.freebsd.org/changeset/base/235125

Log:
  MFC r234131:
  	Return EBADF instead of EMFILE from dup2 when the second argument is
  	outside the range of valid file descriptors
  
  PR:		kern/164970
  Approved by:	cperciva (implicit)

Modified:
  stable/9/sys/kern/kern_descrip.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/kern_descrip.c
==============================================================================
--- stable/9/sys/kern/kern_descrip.c	Mon May  7 10:50:26 2012	(r235124)
+++ stable/9/sys/kern/kern_descrip.c	Mon May  7 12:19:49 2012	(r235125)
@@ -815,7 +815,7 @@ do_dup(struct thread *td, int flags, int
 	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) {


More information about the svn-src-stable-9 mailing list