From: Michael Schroeder Date: Wed, 18 Jul 2018 19:50:10 +0000 (+0200) Subject: Fix getinstalledrpmdbids handling of the match attribute X-Git-Tag: 0.6.35~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dccf2755fe8724774194ec9794456becbea263f3;p=thirdparty%2Flibsolv.git Fix getinstalledrpmdbids handling of the match attribute We currently have to iterate through all package names because rpm lacks an interface to just get one specific name. --- diff --git a/ext/repo_rpmdb_librpm.h b/ext/repo_rpmdb_librpm.h index 60efb07e..aa901ca1 100644 --- a/ext/repo_rpmdb_librpm.h +++ b/ext/repo_rpmdb_librpm.h @@ -114,7 +114,7 @@ static struct rpmdbentry * getinstalledrpmdbids(struct rpmdbstate *state, const char *index, const char *match, int *nentriesp, char **namedatap) { const void * key; - size_t keylen; + size_t keylen, matchl = 0; Id nameoff; char *namedata = 0; @@ -132,13 +132,19 @@ getinstalledrpmdbids(struct rpmdbstate *state, const char *index, const char *ma if (state->dbenvopened != 1 && !opendbenv(state)) return 0; + if (match) + matchl = strlen(match); ii = rpmdbIndexIteratorInit(rpmtsGetRdb(state->ts), RPMDBI_NAME); while (rpmdbIndexIteratorNext(ii, &key, &keylen) == 0) { - - if (keylen == 10 && !memcmp(key, "gpg-pubkey", 10)) - continue; + if (match) + { + if (keylen != matchl || memcmp(key, match, keylen) != 0) + continue; + } + else if (keylen == 10 && !memcmp(key, "gpg-pubkey", 10)) + continue; nameoff = namedatal; if (namedatap) {