On Apr 14, 2016, at 12:15 PM, Jeff Johnson wrote:

> 
>> >>>> rpm files are generated on x86_64 machines but querying it on ppc 
>> >>>> machines (arch within rpm is ppc). Inbuilt metadata can be queried 
>> >>>> using --qf but not custom metadata. I guessed that endianness should 
>> >>>> not have impact rpm metadata content. But, even if it has, then it 
>> >>>> should give garbled values and not "(none)" as its result. However, 
>> >>>> querying custom metadata works fine in 5.4.14.
>>  
> 
> Yes arbitrary tags in metadata should be platform independent as a goal. But 
> not in rpm-5.1.9 == a bug.
> 

I should state the problem more carefully:

The meatadata and the tags assigned to the arbitrary metadata ARE independent
of platform in the sense that that are marked with 0xc0000000. What is/was 
broken
is that the truncated SHA1 for the remaining 30bits of the tag assignment is 
little
endian.

The fix on PPC and big-endian machines is to swab the 30bits before generating
the tag assignment.

> The tag itself, not its content, is what is not platform independent. Hence 
> not "garbled".
> 

The fix on PPC and big-endian machines is to swab the 30bits before generating
the tag assignment.

So its a fairly simple one line patch in rpmio/tagname in _tagGenerate() in 
rpm-5.1.9
that end up looking should look like this:

    if (digest && digestlen > 4) {
          /* The tag is stored in a uniform byte order for cross-endian 
compatib  ility. 
             Swap to the host uses. */
          memcpy(&tag, digest + (digestlen - 4), 4);
          tag = le32toh(tag);
          tag = (rpmTag) (tag & 0x3fffffff);
          tag = (rpmTag) (tag | 0x40000000);
      }   

73 de Jeff

Reply via email to