Date: Sun, 17 Mar 2002 01:42:33 -0800 (PST) From: Hendrik Scholz <hendrik@scholz.net> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/36000: contrib/amd uses mktemp Message-ID: <200203170942.g2H9gXw96285@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200203170942.g2H9gXw96285>
