From nobody@FreeBSD.org  Sun Mar 17 01:42:34 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id EFB4837B400
	for <freebsd-gnats-submit@FreeBSD.org>; 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 <hendrik@scholz.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: contrib/amd uses mktemp
X-Send-Pr-Version: www-1.0

>Number:         36000
>Category:       bin
>Synopsis:       contrib/amd uses mktemp
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 17 01:50:01 PST 2002
>Closed-Date:    Sat Jul 12 05:25:42 PDT 2003
>Last-Modified:  Sat Jul 12 05:25:42 PDT 2003
>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:
State-Changed-From-To: open->feedback 
State-Changed-By: johan 
State-Changed-When: Mon Jul 22 14:07:55 PDT 2002 
State-Changed-Why:  
Can you report this to the amd developers and ask them 
to change this in the vendor code, please. Then we can import 
the change from them. The email address is 
amd-dev@majordomo.cs.columbia.edu 

Please, also report back when they have made the change 
so we know when we should import the new version. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=36000 
State-Changed-From-To: feedback->closed 
State-Changed-By: kris 
State-Changed-When: Sat Jul 12 05:25:22 PDT 2003 
State-Changed-Why:  
Feedback timeout 

http://www.freebsd.org/cgi/query-pr.cgi?pr=36000 
>Unformatted:
