Thu Oct 22 22:51:29 2009 UTC ()
pkg_install-20091022:
Do not overwrite a string with itself using snprintf. This breaks
setting the pkgdb directory internally on Linux. Explicitly check
if the string is the same and otherwise just use xstrdup.


(joerg)
diff -r1.35 -r1.36 pkgsrc/pkgtools/pkg_install/files/lib/pkgdb.c
diff -r1.141 -r1.142 pkgsrc/pkgtools/pkg_install/files/lib/version.h

cvs diff -r1.35 -r1.36 pkgsrc/pkgtools/pkg_install/files/lib/pkgdb.c (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/lib/pkgdb.c 2009/09/11 18:00:13 1.35
+++ pkgsrc/pkgtools/pkg_install/files/lib/pkgdb.c 2009/10/22 22:51:29 1.36
@@ -1,23 +1,23 @@ @@ -1,23 +1,23 @@
1/* $NetBSD: pkgdb.c,v 1.35 2009/09/11 18:00:13 joerg Exp $ */ 1/* $NetBSD: pkgdb.c,v 1.36 2009/10/22 22:51:29 joerg Exp $ */
2 2
3#if HAVE_CONFIG_H 3#if HAVE_CONFIG_H
4#include "config.h" 4#include "config.h"
5#endif 5#endif
6#include <nbcompat.h> 6#include <nbcompat.h>
7#if HAVE_SYS_CDEFS_H 7#if HAVE_SYS_CDEFS_H
8#include <sys/cdefs.h> 8#include <sys/cdefs.h>
9#endif 9#endif
10__RCSID("$NetBSD: pkgdb.c,v 1.35 2009/09/11 18:00:13 joerg Exp $"); 10__RCSID("$NetBSD: pkgdb.c,v 1.36 2009/10/22 22:51:29 joerg Exp $");
11 11
12/*- 12/*-
13 * Copyright (c) 1999-2008 The NetBSD Foundation, Inc. 13 * Copyright (c) 1999-2008 The NetBSD Foundation, Inc.
14 * All rights reserved. 14 * All rights reserved.
15 * 15 *
16 * This code is derived from software contributed to The NetBSD Foundation 16 * This code is derived from software contributed to The NetBSD Foundation
17 * by Hubert Feyrer <hubert@feyrer.de>. 17 * by Hubert Feyrer <hubert@feyrer.de>.
18 * 18 *
19 * Redistribution and use in source and binary forms, with or without 19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions 20 * modification, are permitted provided that the following conditions
21 * are met: 21 * are met:
22 * 1. Redistributions of source code must retain the above copyright 22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer. 23 * notice, this list of conditions and the following disclaimer.
@@ -68,27 +68,26 @@ __RCSID("$NetBSD: pkgdb.c,v 1.35 2009/09 @@ -68,27 +68,26 @@ __RCSID("$NetBSD: pkgdb.c,v 1.35 2009/09
68 68
69/* 69/*
70 * Where we put logging information by default if PKG_DBDIR is unset. 70 * Where we put logging information by default if PKG_DBDIR is unset.
71 */ 71 */
72#ifndef DEF_LOG_DIR 72#ifndef DEF_LOG_DIR
73#define DEF_LOG_DIR "/var/db/pkg" 73#define DEF_LOG_DIR "/var/db/pkg"
74#endif 74#endif
75 75
76/* just in case we change the environment variable name */ 76/* just in case we change the environment variable name */
77#define PKG_DBDIR "PKG_DBDIR" 77#define PKG_DBDIR "PKG_DBDIR"
78 78
79static DB *pkgdbp; 79static DB *pkgdbp;
80static char *pkgdb_dir = NULL; 80static char *pkgdb_dir = NULL;
81static char pkgdb_cache[MaxPathSize]; 
82 81
83/* 82/*
84 * Open the pkg-database 83 * Open the pkg-database
85 * Return value: 84 * Return value:
86 * 1: everything ok 85 * 1: everything ok
87 * 0: error 86 * 0: error
88 */ 87 */
89int 88int
90pkgdb_open(int mode) 89pkgdb_open(int mode)
91{ 90{
92 BTREEINFO info; 91 BTREEINFO info;
93 char cachename[MaxPathSize]; 92 char cachename[MaxPathSize];
94 93
@@ -300,22 +299,27 @@ _pkgdb_getPKGDB_DIR(void) @@ -300,22 +299,27 @@ _pkgdb_getPKGDB_DIR(void)
300 else 299 else
301 _pkgdb_setPKGDB_DIR(DEF_LOG_DIR); 300 _pkgdb_setPKGDB_DIR(DEF_LOG_DIR);
302 } 301 }
303 302
304 return pkgdb_dir; 303 return pkgdb_dir;
305} 304}
306 305
307/* 306/*
308 * Set the first place we look for where pkgdb is stored. 307 * Set the first place we look for where pkgdb is stored.
309 */ 308 */
310void 309void
311_pkgdb_setPKGDB_DIR(const char *dir) 310_pkgdb_setPKGDB_DIR(const char *dir)
312{ 311{
313 (void) snprintf(pkgdb_cache, sizeof(pkgdb_cache), "%s", dir); 312 char *new_dir;
314 pkgdb_dir = pkgdb_cache; 313
 314 if (dir == pkgdb_dir)
 315 return;
 316 new_dir = xstrdup(dir);
 317 free(pkgdb_dir);
 318 pkgdb_dir = new_dir;
315} 319}
316 320
317char * 321char *
318pkgdb_pkg_file(const char *pkg, const char *file) 322pkgdb_pkg_file(const char *pkg, const char *file)
319{ 323{
320 return xasprintf("%s/%s/%s", _pkgdb_getPKGDB_DIR(), pkg, file); 324 return xasprintf("%s/%s/%s", _pkgdb_getPKGDB_DIR(), pkg, file);
321} 325}

cvs diff -r1.141 -r1.142 pkgsrc/pkgtools/pkg_install/files/lib/version.h (expand / switch to unified diff)

--- pkgsrc/pkgtools/pkg_install/files/lib/version.h 2009/10/21 17:10:36 1.141
+++ pkgsrc/pkgtools/pkg_install/files/lib/version.h 2009/10/22 22:51:29 1.142
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: version.h,v 1.141 2009/10/21 17:10:36 joerg Exp $ */ 1/* $NetBSD: version.h,v 1.142 2009/10/22 22:51:29 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001 Thomas Klausner. All rights reserved. 4 * Copyright (c) 2001 Thomas Klausner. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -17,16 +17,16 @@ @@ -17,16 +17,16 @@
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27#ifndef _INST_LIB_VERSION_H_ 27#ifndef _INST_LIB_VERSION_H_
28#define _INST_LIB_VERSION_H_ 28#define _INST_LIB_VERSION_H_
29 29
30#define PKGTOOLS_VERSION "20091021" 30#define PKGTOOLS_VERSION "20091022"
31 31
32#endif /* _INST_LIB_VERSION_H_ */ 32#endif /* _INST_LIB_VERSION_H_ */