summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rpm/rpm/rpm-tag-generate-endian-conversion-fix.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/rpm/rpm/rpm-tag-generate-endian-conversion-fix.patch')
-rw-r--r--meta/recipes-devtools/rpm/rpm/rpm-tag-generate-endian-conversion-fix.patch50
1 files changed, 50 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rpm/rpm/rpm-tag-generate-endian-conversion-fix.patch b/meta/recipes-devtools/rpm/rpm/rpm-tag-generate-endian-conversion-fix.patch
new file mode 100644
index 0000000000..683275cb18
--- /dev/null
+++ b/meta/recipes-devtools/rpm/rpm/rpm-tag-generate-endian-conversion-fix.patch
@@ -0,0 +1,50 @@
1fix a endian incompatible error in generating rpm tag
2
3A flaw was found in the way rpm generating arbitrary tags, which leads to a
4incorrect query result, this issue is introduced by a incompatible endianess
5when the generating process is executed on different architectures.
6
7This patch resolves it by taking the byte order that host uses.
8
9Upstream-Status: Pending
10
11Signed-off-by: Ming Liu <ming.liu@windriver.com>
12---
13 tagname.c | 16 ++++++++++++++++
14 1 file changed, 16 insertions(+)
15
16Index: rpm-5.4.14/rpmdb/tagname.c
17===================================================================
18--- rpm-5.4.14.orig/rpmdb/tagname.c
19+++ rpm-5.4.14/rpmdb/tagname.c
20@@ -3,6 +3,19 @@
21 */
22
23 #include "system.h"
24+#include <endian.h>
25+
26+/* Don't redefine this macro if it already exists */
27+#ifndef le32toh
28+#ifdef __USE_BSD
29+#include <byteswap.h>
30+#if __BYTE_ORDER == __LITTLE_ENDIAN
31+#define le32toh(x) (x)
32+#else
33+#define le32toh(x) __bswap_32(x)
34+#endif
35+#endif /* __USE_BSD */
36+#endif /* le32toh */
37
38 #include <rpmio_internal.h> /* XXX DIGEST_CTX, xtolower, xstrcasecmp */
39 #include <rpmmacro.h>
40@@ -152,7 +165,10 @@ static rpmTag _tagGenerate(const char *s
41 xx = rpmDigestUpdate(ctx, s, nb);
42 xx = rpmDigestFinal(ctx, &digest, &digestlen, 0);
43 if (digest && digestlen > 4) {
44+ /* The tag is stored in a uniform byte order for cross-endian compatibility.
45+ Swap to the host uses. */
46 memcpy(&tag, digest + (digestlen - 4), 4);
47+ tag = le32toh(tag);
48 tag = (rpmTag) (tag & 0x3fffffff);
49 tag = (rpmTag) (tag | 0x40000000);
50 }