From owner-freebsd-standards@FreeBSD.ORG Sun Jun 5 19:12:49 2005 Return-Path: X-Original-To: freebsd-standards@freebsd.org Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E34C316A41C for ; Sun, 5 Jun 2005 19:12:49 +0000 (GMT) (envelope-from liamfoy@sepulcrum.org) Received: from moutvdomng.kundenserver.de (moutvdom.kundenserver.de [212.227.126.249]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8CF6143D1D for ; Sun, 5 Jun 2005 19:12:47 +0000 (GMT) (envelope-from liamfoy@sepulcrum.org) Received: from [212.227.126.224] (helo=mrvdomng.kundenserver.de) by moutvdomng.kundenserver.de with esmtp (Exim 3.35 #1) id 1Df0YA-0005xN-00 for freebsd-standards@freebsd.org; Sun, 05 Jun 2005 21:12:46 +0200 Received: from host217-42-173-197.range217-42.btcentralplus.com ([217.42.173.197] helo=localhost) by mrvdomng.kundenserver.de with esmtp (Exim 3.35 #1) id 1Df0YA-0003wU-00 for freebsd-standards@freebsd.org; Sun, 05 Jun 2005 21:12:46 +0200 Date: Sun, 5 Jun 2005 20:12:41 +0100 From: "Liam J. Foy" To: freebsd-standards@freebsd.org Message-ID: <20050605191241.GA14672@anarion> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.8i Subject: setmode patches X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jun 2005 19:12:50 -0000 Hey guys, I want to show you all some patches: http://metawire.org/~liamfoy/setmode.c.diff.f http://metawire.org/~liamfoy/setmode.3.diff.f This will allow errno to be set in all cases to ERANGE. We can then check this in applications which use setmode(3). Most usage of setmode(3) assumes that that setmode will fail due to an invalid file mode. Example: This snip is from chmod.c: [snip] if (hflag) change_mode = lchmod; else change_mode = chmod; mode = *argv; if ((set = setmode(mode)) == NULL) errx(1, "invalid file mode: %s", mode); if ((ftsp = fts_open(++argv, fts_options, 0)) == NULL) err(1, "fts_open"); for (rval = 0; (p = fts_read(ftsp)) != NULL;) { [snip] However, setmode(3) can fail due to malloc. With the following patch, we can show whether it was actually a bad file mode or something else (malloc): http://metawire.org/~liamfoy/chmod.c.diff.f Anyone have any comments/suggestions? There are also many other instances where setmode is assumed to fail due to a invalid file mode only (I can also create these patches). Cheers, -- - Liam J. Foy liamfoy@sepulcrum.org