On Aug 26, 2013, at 3:42 PM, Per Øyvind Karlsen wrote:
This patch fixes tagSwab() to work with RPM_UINT64_TYPE.
I'm not sure why it's not using newer functions (ie. from endian(3)) with
support for 64 integers rather than using two 32 bit integers, but I guess it
might be related to legacy compatibility..?
And if so, is it still relevant, or should code be updated?
(I first did the fix with 64 bit swab function, but then figured that it
might not be all too welcome upstream)
Oh well, either way, this patch makes it anyways work though. :)
Patch looks correct, but there's likely other places that need fixing.
Yes this is ancient hysterically remnant code when unsigned long long
wasn't reliably/portably implemented.
There are no RPMTAG_* tags with RPM_UINT64_TYPE (though
@rpm.org may have added something).
Without a usage case, carrying around support for RPM_UNIT64_TYPE
is largely an unnecessary pointless task. Meanwhile there are most definitely
uses for UINT64 these days, just adding a mandatory tag with a UINT64 type
introduces instant legacy incompatibility and confusion at least at the
level of, say, changing to SHA256 or XZ compression.
Sure you can wave your hands (as @rpm.org may have done, not checked, dunno) and
make the use of UINT64 tags conditionally opt-in somehow.
I chose to fix slightly differently:
Index: header.c
===
RCS file: /v/rpm/cvs/rpm/rpmdb/header.c,v
retrieving revision 1.198.2.8
diff -p -u -w -r1.198.2.8 header.c
--- header.c28 Jun 2013 16:57:10 - 1.198.2.8
+++ header.c26 Aug 2013 21:34:57 -
@@ -398,7 +398,7 @@ static unsigned char * tagSwab(/*@out@*/
switch (he-t) {
case RPM_UINT64_TYPE:
{ rpmuint32_t * tt = (rpmuint32_t *)t;
-assert(nb == (he-c * sizeof(*tt)));
+assert(nb == (2 * he-c * sizeof(*tt)));
for (i = 0; i he-c; i++) {
rpmuint32_t j = 2 * i;
rpmuint32_t b = (rpmuint32_t) htonl(he-p.ui32p[j]);
--
Regards,
Per Øyvind
rpm-5.4.10-fix-64bit-tagSwab.patch
__
RPM Package Managerhttp://rpm5.org
Developer Communication Listrpm-devel@rpm5.org