Module Name: src Committed By: christos Date: Sun May 19 15:56:55 UTC 2024
Modified Files: src/sys/kern: sys_descrip.c Log Message: PR/58266: Collin Funk: Fail if from == to, like FreeBSD and Linux. The test is done in dup3 before any other tests so even if a bad descriptor it is passed we will return EINVAL not EBADFD like Linux does. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/kern/sys_descrip.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/sys_descrip.c diff -u src/sys/kern/sys_descrip.c:1.48 src/sys/kern/sys_descrip.c:1.49 --- src/sys/kern/sys_descrip.c:1.48 Sun Jul 9 22:31:55 2023 +++ src/sys/kern/sys_descrip.c Sun May 19 11:56:55 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: sys_descrip.c,v 1.48 2023/07/10 02:31:55 christos Exp $ */ +/* $NetBSD: sys_descrip.c,v 1.49 2024/05/19 15:56:55 christos Exp $ */ /*- * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.48 2023/07/10 02:31:55 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sys_descrip.c,v 1.49 2024/05/19 15:56:55 christos Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -156,6 +156,8 @@ sys_dup3(struct lwp *l, const struct sys syscallarg(int) to; syscallarg(int) flags; } */ + if (SCARG(uap, from) == SCARG(uap, to)) + return EINVAL; return dodup(l, SCARG(uap, from), SCARG(uap, to), SCARG(uap, flags), retval); }