Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-6]: src/usr.bin/cap_mkdb Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/10f1e177e0dc
branches:  netbsd-6
changeset: 775752:10f1e177e0dc
user:      riz <riz%NetBSD.org@localhost>
date:      Sun Mar 31 20:39:38 2013 +0000

description:
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.

diffstat:

 usr.bin/cap_mkdb/cap_mkdb.c |  22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

diffs (68 lines):

diff -r 45129936dc84 -r 10f1e177e0dc usr.bin/cap_mkdb/cap_mkdb.c
--- a/usr.bin/cap_mkdb/cap_mkdb.c       Sun Mar 31 20:36:23 2013 +0000
+++ b/usr.bin/cap_mkdb/cap_mkdb.c       Sun Mar 31 20:39:38 2013 +0000
@@ -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 @@
 #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 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 @@
         * 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 @@
 
        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 @@
 dounlink(void)
 {
        if (capname != NULL)
-               (void)unlink(capname);
+               unlink(capname);
 }
 
 /*



Home | Main Index | Thread Index | Old Index