strlen(pkgname) only returns the number of characters preceding the NUL,

but the size of the data field in the pkgdb.byfile.db file is the length of
the string plus 1 for the NUL.  Fix this check so that removing all of the
files belonging to pkgname from pkgdb.byfile.db works again.
This commit is contained in:
jlam 2003-09-08 06:41:23 +00:00
parent a7155b9951
commit 140fe23a05
1 changed files with 3 additions and 3 deletions

View File

@ -1,8 +1,8 @@
/* $NetBSD: pkgdb.c,v 1.16 2003/09/08 05:34:35 jlam Exp $ */
/* $NetBSD: pkgdb.c,v 1.17 2003/09/08 06:41:23 jlam Exp $ */
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: pkgdb.c,v 1.16 2003/09/08 05:34:35 jlam Exp $");
__RCSID("$NetBSD: pkgdb.c,v 1.17 2003/09/08 06:41:23 jlam Exp $");
#endif
/*
@ -217,7 +217,7 @@ pkgdb_remove_pkg(const char *pkg)
}
cc = strlen(pkg);
for (ret = 1, type = R_FIRST; (*pkgdbp->seq)(pkgdbp, &key, &data, type) == 0 ; type = R_NEXT) {
if (cc == data.size && strncmp(data.data, pkg, cc) == 0) {
if ((cc + 1) == data.size && strncmp(data.data, pkg, cc) == 0) {
if (Verbose) {
printf("Removing file %s from pkgdb\n", (char *)key.data);
}