[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rpm-users
Subject:    Re: rpm 5.1.9 issues on powerPC architecture
From:       Jeff Johnson <n3npq () mac ! com>
Date:       2016-04-14 16:31:43
Message-ID: F206B05F-A319-4F08-8C25-0ADB2696A3D9 () mac ! com
[Download RAW message or body]

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


[Attachment #3 (unknown)]

<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space; "><br><div><div>On Apr 14, 2016, at 12:15 PM, \
Jeff Johnson wrote:</div><br class="Apple-interchange-newline"><blockquote \
type="cite"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; \
-webkit-line-break: after-white-space; "><br><div><blockquote type="cite"><div \
dir="ltr"><div><div><div><div class="gmail_extra"><div \
class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div \
style="word-wrap:break-word"><div><span class="">&gt;&gt;&gt;&gt; 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.<br></span></div></div></blockquote><div>&nbsp;</div></div></div></div></div></div></div></blockquote><div><br></div>Yes \
arbitrary tags in metadata should be platform independent as a goal. But not in \
rpm-5.1.9 == a bug.</div><div><br></div></div></blockquote><div><br></div>I should \
state the problem more carefully:</div><div><br></div><div>The meatadata and the tags \
assigned to the arbitrary metadata ARE independent</div><div>of platform in the sense \
that that are marked with 0xc0000000. What is/was broken</div><div>is that the \
truncated SHA1 for the remaining 30bits of the tag assignment is \
little</div><div>endian.</div><div><br></div><div>The fix on PPC and big-endian \
machines is to swab the 30bits before generating</div><div>the tag \
assignment.</div><div><br></div><div><blockquote type="cite"><div style="word-wrap: \
break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; \
"><div>The tag itself, not its content, is what is not platform independent. Hence \
not "garbled".</div><div><br></div></div></blockquote></div><br><div><div>The fix on \
PPC and big-endian machines is to swab the 30bits before generating</div><div>the tag \
assignment.</div></div><div><br></div><div>So its a fairly simple one line patch in \
rpmio/tagname in _tagGenerate() in rpm-5.1.9</div><div>that end up looking should \
look like this:</div><div><br></div><div><div>&nbsp; &nbsp; if (digest &amp;&amp; \
digestlen &gt; 4) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; /* The tag is stored \
in a uniform byte order for cross-endian compatib &nbsp;ility.&nbsp;</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Swap to the host uses. */</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; memcpy(&amp;tag, digest + (digestlen - 4), \
4);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tag = le32toh(tag);</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; tag = (rpmTag) (tag &amp; 0x3fffffff);</div><div>&nbsp; \
&nbsp; &nbsp; &nbsp; &nbsp; tag = (rpmTag) (tag | 0x40000000);</div><div>&nbsp; \
&nbsp; &nbsp; } &nbsp;&nbsp;</div><div><br></div><div>73 de \
Jeff</div></div></body></html>


______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
User Communication List                             rpm-users@rpm5.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic