From owner-freebsd-bugs@FreeBSD.ORG Sun Apr 2 20:50:29 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DB19516A52F for ; Sun, 2 Apr 2006 20:50:28 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 864F843D69 for ; Sun, 2 Apr 2006 20:50:25 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k32KoPGm051366 for ; Sun, 2 Apr 2006 20:50:25 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k32KoPNg051365; Sun, 2 Apr 2006 20:50:25 GMT (envelope-from gnats) Resent-Date: Sun, 2 Apr 2006 20:50:25 GMT Resent-Message-Id: <200604022050.k32KoPNg051365@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Todd Miller Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 02E3816A45F for ; Sun, 2 Apr 2006 20:43:15 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id A78EB43D48 for ; Sun, 2 Apr 2006 20:43:14 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k32KhEsw082449 for ; Sun, 2 Apr 2006 20:43:14 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id k32KhEGU082448; Sun, 2 Apr 2006 20:43:14 GMT (envelope-from nobody) Message-Id: <200604022043.k32KhEGU082448@www.freebsd.org> Date: Sun, 2 Apr 2006 20:43:14 GMT From: Todd Miller To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-2.3 Cc: Subject: misc/95239: nftw() returns EINVAL for large values of maxfds when it should not X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 02 Apr 2006 20:50:29 -0000 >Number: 95239 >Category: misc >Synopsis: nftw() returns EINVAL for large values of maxfds when it should not >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Apr 02 20:50:24 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Todd Miller >Release: >Organization: >Environment: >Description: The nftw(3) I wrote for OpenBSD that is now used by FreeBSD has a bug where it returns -1 and sets errno to EINVAL when maxfds > OPEN_MAX. However, only the older ftw(3) should have this restriction (see single unix or POSIX). I've inluded the fix I used in OpenBSD but due to the web form submission the patch will likely have to be applied by hand (it is small). >How-To-Repeat: >Fix: Index: ftw.3 =================================================================== RCS file: /home/cvs/freebsd/src/lib/libc/gen/ftw.3,v retrieving revision 1.3 diff -u -r1.3 ftw.3 --- ftw.3 23 Nov 2005 15:41:36 -0000 1.3 +++ ftw.3 2 Apr 2006 20:37:44 -0000 @@ -185,7 +185,10 @@ .It Bq Er EINVAL The .Fa maxfds -argument is less than 1. +argument is less than 1 or, in the case of +.Nm ftw +only, greater than +.Dv OPEN_MAX . .El .Sh SEE ALSO .Xr chdir 2 , Index: nftw.c =================================================================== RCS file: /home/cvs/freebsd/src/lib/libc/gen/nftw.c,v retrieving revision 1.1 diff -u -r1.1 nftw.c --- nftw.c 24 Aug 2004 13:00:55 -0000 1.1 +++ nftw.c 2 Apr 2006 20:37:07 -0000 @@ -34,7 +34,6 @@ #include #include #include -#include int nftw(const char *path, int (*fn)(const char *, const struct stat *, int, @@ -47,7 +46,7 @@ int error = 0, ftsflags, fnflag, postorder, sverrno; /* XXX - nfds is currently unused */ - if (nfds < 1 || nfds > OPEN_MAX) { + if (nfds < 1) { errno = EINVAL; return (-1); } >Release-Note: >Audit-Trail: >Unformatted: