Module Name: src
Committed By: riz
Date: Sun Mar 31 20:39:39 UTC 2013
Modified Files:
src/usr.bin/cap_mkdb [netbsd-6]: cap_mkdb.c
Log Message:
Pull up following revision(s) (requested by gdt in ticket #858):
usr.bin/cap_mkdb/cap_mkdb.c: revision 1.28
usr.bin/cap_mkdb/cap_mkdb.c: revision 1.29
Move assignment out of assertion in cap_mkdb.
PR/32591: JuanRP: Also remove the file we are going to be building to prevent
it from being used as input.
To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.27.4.1 src/usr.bin/cap_mkdb/cap_mkdb.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/cap_mkdb/cap_mkdb.c
diff -u src/usr.bin/cap_mkdb/cap_mkdb.c:1.27 src/usr.bin/cap_mkdb/cap_mkdb.c:1.27.4.1
--- src/usr.bin/cap_mkdb/cap_mkdb.c:1.27 Mon Aug 29 13:56:17 2011
+++ src/usr.bin/cap_mkdb/cap_mkdb.c Sun Mar 31 20:39:38 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: cap_mkdb.c,v 1.27 2011/08/29 13:56:17 joerg Exp $ */
+/* $NetBSD: cap_mkdb.c,v 1.27.4.1 2013/03/31 20:39:38 riz Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19
#if 0
static char sccsid[] = "@(#)cap_mkdb.c 8.2 (Berkeley) 4/27/95";
#endif
-__RCSID("$NetBSD: cap_mkdb.c,v 1.27 2011/08/29 13:56:17 joerg Exp $");
+__RCSID("$NetBSD: cap_mkdb.c,v 1.27.4.1 2013/03/31 20:39:38 riz Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -63,7 +63,7 @@ static int count_records(char **);
static DB *capdbp;
static int verbose;
-static char *capname, buf[8 * 1024];
+static char *capname, outfile[MAXPATHLEN];
static HASHINFO openinfo = {
4096, /* bsize */
@@ -126,13 +126,17 @@ main(int argc, char *argv[])
* The database file is the first argument if no name is specified.
* Make arrangements to unlink it if exit badly.
*/
- (void)snprintf(buf, sizeof(buf), "%s.db.tmp",
+ (void)snprintf(outfile, sizeof(outfile), "%s.db.tmp",
capname ? capname : *argv);
- if ((capname = strdup(buf)) == NULL)
+ if ((capname = strdup(outfile)) == NULL)
err(1, "strdup");
+ p = strrchr(outfile, '.');
+ assert(p != NULL);
+ *p = '\0';
+ (void)unlink(outfile);
if ((capdbp = dbopen(capname, O_CREAT | O_TRUNC | O_RDWR,
DEFFILEMODE, DB_HASH, &openinfo)) == NULL)
- err(1, "%s", buf);
+ err(1, "%s", outfile);
if (atexit(dounlink))
err(1, "atexit");
@@ -141,9 +145,7 @@ main(int argc, char *argv[])
if (capdbp->close(capdbp) < 0)
err(1, "%s", capname);
- assert((p = strrchr(buf, '.')) != NULL);
- *p = '\0';
- if (rename(capname, buf) == -1)
+ if (rename(capname, outfile) == -1)
err(1, "rename");
free(capname);
capname = NULL;
@@ -154,7 +156,7 @@ static void
dounlink(void)
{
if (capname != NULL)
- (void)unlink(capname);
+ unlink(capname);
}
/*