From owner-freebsd-bugs Sun Mar 17 1:50: 6 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 3894B37B402 for ; Sun, 17 Mar 2002 01:50:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2H9o1I97257; Sun, 17 Mar 2002 01:50:01 -0800 (PST) (envelope-from gnats) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id EFB4837B400 for ; Sun, 17 Mar 2002 01:42:33 -0800 (PST) Received: (from nobody@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2H9gXw96285; Sun, 17 Mar 2002 01:42:33 -0800 (PST) (envelope-from nobody) Message-Id: <200203170942.g2H9gXw96285@freefall.freebsd.org> Date: Sun, 17 Mar 2002 01:42:33 -0800 (PST) From: Hendrik Scholz To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: bin/36000: contrib/amd uses mktemp Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 36000 >Category: bin >Synopsis: contrib/amd uses mktemp >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 Mar 17 01:50:01 PST 2002 >Closed-Date: >Last-Modified: >Originator: Hendrik Scholz >Release: 5.0 current x86 >Organization: >Environment: FreeBSD deimos.raisdorf.net 5.0-CURRENT FreeBSD 5.0-CURRENT #6: Sun Mar 17 19:26:49 EST 2002 hscholz@deimos.raisdorf.net:/usr/src/sys/i386/compile/DEIMOS5 i386 >Description: mk-amd-map(8) from amd(8) uses mktemp() to get a unique filename for a temporary file. It cannot be ported to mkstemp() because it later on does a dbm_open(), so it should be better to add O_EXCL to the dbm_open() flags so it would return an error if the file already exists. >How-To-Repeat: look at src/contrib/amd/mk-amd-map/mk-amd-map.c there is mktemp(maptmp); around line 290 and at line 310 there is: db = dbm_open(maptmp, O_RDWR|O_CREAT, 0444); Errors produced by dbm_open() are handled. >Fix: --- mk-amd-map.c.orig Sun Mar 17 19:34:33 2002 +++ mk-amd-map.c Sun Mar 17 19:34:51 2002 @@ -307,7 +307,7 @@ } #endif /* not HAVE_DB_SUFFIX */ - db = dbm_open(maptmp, O_RDWR|O_CREAT, 0444); + db = dbm_open(maptmp, O_RDWR|O_CREAT|O_EXCL, 0444); if (!db) { fprintf(stderr, "cannot initialize temporary database: %s", maptmp); exit(1); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message