Tue Apr 20 21:22:38 2010 UTC ()
pkg_install-20100421:
Fix an off-by-one in the check for properly sized pkgdb entries.
It rejected perfectly valid entries.


(joerg)
diff -r1.38 -r1.39 pkgsrc/pkgtools/pkg_install/files/lib/pkgdb.c
diff -r1.154 -r1.155 pkgsrc/pkgtools/pkg_install/files/lib/version.h

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

--- pkgsrc/pkgtools/pkg_install/files/lib/pkgdb.c 2010/04/14 18:24:58 1.38
+++ pkgsrc/pkgtools/pkg_install/files/lib/pkgdb.c 2010/04/20 21:22:38 1.39
@@ -1,23 +1,23 @@ @@ -1,23 +1,23 @@
1/* $NetBSD: pkgdb.c,v 1.38 2010/04/14 18:24:58 joerg Exp $ */ 1/* $NetBSD: pkgdb.c,v 1.39 2010/04/20 21:22:38 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.38 2010/04/14 18:24:58 joerg Exp $"); 10__RCSID("$NetBSD: pkgdb.c,v 1.39 2010/04/20 21:22:38 joerg Exp $");
11 11
12/*- 12/*-
13 * Copyright (c) 1999-2010 The NetBSD Foundation, Inc. 13 * Copyright (c) 1999-2010 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.
@@ -174,27 +174,27 @@ pkgdb_retrieve(const char *key) @@ -174,27 +174,27 @@ pkgdb_retrieve(const char *key)
174 if (pkgdbp == NULL) 174 if (pkgdbp == NULL)
175 return NULL; 175 return NULL;
176 176
177 keyd.data = __UNCONST(key); 177 keyd.data = __UNCONST(key);
178 keyd.size = strlen(key) + 1; 178 keyd.size = strlen(key) + 1;
179 errno = 0; /* to be sure it's 0 if the key doesn't match anything */ 179 errno = 0; /* to be sure it's 0 if the key doesn't match anything */
180 180
181 vald.data = (void *)NULL; 181 vald.data = (void *)NULL;
182 vald.size = 0; 182 vald.size = 0;
183 status = (*pkgdbp->get) (pkgdbp, &keyd, &vald, 0); 183 status = (*pkgdbp->get) (pkgdbp, &keyd, &vald, 0);
184 if (status) 184 if (status)
185 return NULL; 185 return NULL;
186 eos = memchr(vald.data, 0, vald.size); 186 eos = memchr(vald.data, 0, vald.size);
187 if (eos == NULL || eos != (char *)vald.data + vald.size) { 187 if (eos == NULL || eos + 1 != (char *)vald.data + vald.size) {
188 if (!corruption_warning) { 188 if (!corruption_warning) {
189 warnx("pkgdb corrupted, please run ``pkg_admin rebuild''"); 189 warnx("pkgdb corrupted, please run ``pkg_admin rebuild''");
190 corruption_warning = 1; 190 corruption_warning = 1;
191 } 191 }
192 return NULL; 192 return NULL;
193 } 193 }
194 194
195 return vald.data; 195 return vald.data;
196} 196}
197 197
198/* dump contents of the database to stdout */ 198/* dump contents of the database to stdout */
199int 199int
200pkgdb_dump(void) 200pkgdb_dump(void)

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

--- pkgsrc/pkgtools/pkg_install/files/lib/version.h 2010/04/20 00:39:13 1.154
+++ pkgsrc/pkgtools/pkg_install/files/lib/version.h 2010/04/20 21:22:38 1.155
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: version.h,v 1.154 2010/04/20 00:39:13 joerg Exp $ */ 1/* $NetBSD: version.h,v 1.155 2010/04/20 21:22:38 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 20100420 30#define PKGTOOLS_VERSION 20100421
31 31
32#endif /* _INST_LIB_VERSION_H_ */ 32#endif /* _INST_LIB_VERSION_H_ */