[Rpm-maint] [PATCH] Add RPMTAG_IDENTITY calculation as tag extension
Panu Matilainen
pmatilai at redhat.com
Wed Apr 4 09:47:18 UTC 2018
On 04/04/2018 11:01 AM, Panu Matilainen wrote:
[...]
>> +static int identityTag(Header h, rpmtd td, headerGetFlags hgflags)
>> +{
>> + int rc = 1;
>> + unsigned int bsize;
>> + void * hb;
>> + DIGEST_CTX ctx;
>> + char * identity = NULL;
>> +
>> + struct rpmtd_s ttd;
>> + Header ih = headerNew();
>> + HeaderIterator hi = headerInitIterator(h);
>> +
>> + while (headerNext(hi, &ttd) && rc) {
>> + if (rpmtdCount(&ttd) > 0) {
>> + if (!identityFilter(ttd.tag))
>> + rc = headerPut(ih, &ttd, HEADERPUT_DEFAULT);
>> + }
>> + rpmtdFreeData(&ttd);
>> + }
>> + headerFreeIterator(hi);
>> +
>> + if (!rc)
>> + return 0;
>> +
>> + hb = headerExport(ih, &bsize);
Forgot to bring this up on the first round: another question is whether
it actually makes sense to go through all this trouble of copying the
header, then exporting it and calculating the digest from that.
It'd be considerably cheaper to calculate a digest on the go while
iterating over the data (from the immutable region, see my other email).
A newly imported header is guaranteed to be sorted (by tags) so it's
consistent.
- Panu -
More information about the Rpm-maint
mailing list