Skip to content

Commit dccf275

Browse files
committed
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.
1 parent 98bf072 commit dccf275

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

ext/repo_rpmdb_librpm.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ static struct rpmdbentry *
114114
getinstalledrpmdbids(struct rpmdbstate *state, const char *index, const char *match, int *nentriesp, char **namedatap)
115115
{
116116
const void * key;
117-
size_t keylen;
117+
size_t keylen, matchl = 0;
118118
Id nameoff;
119119

120120
char *namedata = 0;
@@ -132,13 +132,19 @@ getinstalledrpmdbids(struct rpmdbstate *state, const char *index, const char *ma
132132
if (state->dbenvopened != 1 && !opendbenv(state))
133133
return 0;
134134

135+
if (match)
136+
matchl = strlen(match);
135137
ii = rpmdbIndexIteratorInit(rpmtsGetRdb(state->ts), RPMDBI_NAME);
136138

137139
while (rpmdbIndexIteratorNext(ii, &key, &keylen) == 0)
138140
{
139-
140-
if (keylen == 10 && !memcmp(key, "gpg-pubkey", 10))
141-
continue;
141+
if (match)
142+
{
143+
if (keylen != matchl || memcmp(key, match, keylen) != 0)
144+
continue;
145+
}
146+
else if (keylen == 10 && !memcmp(key, "gpg-pubkey", 10))
147+
continue;
142148
nameoff = namedatal;
143149
if (namedatap)
144150
{

0 commit comments

Comments
 (0)