From 79aa86ab901cbbf3db1442f12e3866bec8a9e8ad Mon Sep 17 00:00:00 2001 From: joerg Date: Wed, 25 Apr 2018 12:20:53 +0000 Subject: pkg_install-20180425: correctly detect package names in PKG_DBDIR If PKG_DBDIR is /foo and a path like /foobar is given, it is not below PKG_DBDIR, so don't translate it into a package name look up. The old logic for giving a path to PKG_DBDIR remains for legacy compat. --- pkgtools/pkg_install/files/info/main.c | 16 ++++++++++------ pkgtools/pkg_install/files/lib/version.h | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'pkgtools/pkg_install') diff --git a/pkgtools/pkg_install/files/info/main.c b/pkgtools/pkg_install/files/info/main.c index 82b0e1d158b..6827443f07f 100644 --- a/pkgtools/pkg_install/files/info/main.c +++ b/pkgtools/pkg_install/files/info/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.31 2012/12/17 04:34:02 agc Exp $ */ +/* $NetBSD: main.c,v 1.32 2018/04/25 12:20:53 joerg Exp $ */ #if HAVE_CONFIG_H #include "config.h" @@ -7,7 +7,7 @@ #if HAVE_SYS_CDEFS_H #include #endif -__RCSID("$NetBSD: main.c,v 1.31 2012/12/17 04:34:02 agc Exp $"); +__RCSID("$NetBSD: main.c,v 1.32 2018/04/25 12:20:53 joerg Exp $"); /* * @@ -299,12 +299,16 @@ main(int argc, char **argv) errx(EXIT_FAILURE, "Error during search in pkgdb for %s", *argv); } } else { - const char *dbdir; + const char *dbdir; + size_t dbdirlen; dbdir = pkgdb_get_dir(); - if (**argv == '/' && strncmp(*argv, dbdir, strlen(dbdir)) == 0) { - *argv += strlen(dbdir) + 1; - if ((*argv)[strlen(*argv) - 1] == '/') { + dbdirlen = strlen(dbdir); + if (**argv == '/' && + strncmp(*argv, dbdir, dbdirlen) == 0 && + (*argv)[dbdirlen] == '/') { + *argv += dbdirlen + 1; + if (**argv && (*argv)[strlen(*argv) - 1] == '/') { (*argv)[strlen(*argv) - 1] = 0; } } diff --git a/pkgtools/pkg_install/files/lib/version.h b/pkgtools/pkg_install/files/lib/version.h index 16338d199f1..03501330653 100644 --- a/pkgtools/pkg_install/files/lib/version.h +++ b/pkgtools/pkg_install/files/lib/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.175 2018/04/17 12:52:35 jperkin Exp $ */ +/* $NetBSD: version.h,v 1.176 2018/04/25 12:20:54 joerg Exp $ */ /* * Copyright (c) 2001 Thomas Klausner. All rights reserved. @@ -27,6 +27,6 @@ #ifndef _INST_LIB_VERSION_H_ #define _INST_LIB_VERSION_H_ -#define PKGTOOLS_VERSION 20180417 +#define PKGTOOLS_VERSION 20180425 #endif /* _INST_LIB_VERSION_H_ */ -- cgit v1.2.3