summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-extended')
-rw-r--r--meta/recipes-extended/cracklib/cracklib/0001-packlib.c-support-dictionary-byte-order-dependent.patch120
1 files changed, 65 insertions, 55 deletions
diff --git a/meta/recipes-extended/cracklib/cracklib/0001-packlib.c-support-dictionary-byte-order-dependent.patch b/meta/recipes-extended/cracklib/cracklib/0001-packlib.c-support-dictionary-byte-order-dependent.patch
index fc402eed13..8e0f40642a 100644
--- a/meta/recipes-extended/cracklib/cracklib/0001-packlib.c-support-dictionary-byte-order-dependent.patch
+++ b/meta/recipes-extended/cracklib/cracklib/0001-packlib.c-support-dictionary-byte-order-dependent.patch
@@ -10,25 +10,38 @@ load them. This could fix the endian issue on multiple platform.
10 10
11Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> 11Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
12Upstream-Status: Pending 12Upstream-Status: Pending
13
14We can't use the endian.h, htobe* and be*toh functions because they are
15not available on older versions of glibc, such as that found in RHEL
165.9.
17
18Change to checking endian and directly calling bswap_* as defined in
19byteswap.h.
20
21Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
22
13--- 23---
14 lib/packlib.c | 208 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 24 lib/packlib.c | 208 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
15 1 file changed, 204 insertions(+), 4 deletions(-) 25 1 file changed, 204 insertions(+), 4 deletions(-)
16 26
17diff --git a/lib/packlib.c b/lib/packlib.c 27Index: cracklib-2.8.22/lib/packlib.c
18index 8f32d14..323ee83 100644 28===================================================================
19--- a/lib/packlib.c 29--- cracklib-2.8.22.orig/lib/packlib.c
20+++ b/lib/packlib.c 30+++ cracklib-2.8.22/lib/packlib.c
21@@ -16,6 +16,9 @@ 31@@ -16,6 +16,12 @@
22 #ifdef HAVE_STDINT_H 32 #ifdef HAVE_STDINT_H
23 #include <stdint.h> 33 #include <stdint.h>
24 #endif 34 #endif
25+ 35+
36+#ifndef _BSD_SOURCE
26+#define _BSD_SOURCE /* See feature_test_macros(7) */ 37+#define _BSD_SOURCE /* See feature_test_macros(7) */
38+#endif
27+#include <endian.h> 39+#include <endian.h>
40+#include <byteswap.h>
28 #include "packer.h" 41 #include "packer.h"
29 42
30 static const char vers_id[] = "packlib.c : v2.3p2 Alec Muffett 18 May 1993"; 43 static const char vers_id[] = "packlib.c : v2.3p2 Alec Muffett 18 May 1993";
31@@ -45,6 +48,182 @@ typedef struct 44@@ -45,6 +51,182 @@ typedef struct
32 char data_get[NUMWORDS][MAXWORDLEN]; 45 char data_get[NUMWORDS][MAXWORDLEN];
33 } PWDICT64; 46 } PWDICT64;
34 47
@@ -40,14 +53,14 @@ index 8f32d14..323ee83 100644
40+static int 53+static int
41+IheaderHostToBigEndian(char *pHeader, int nBitType) 54+IheaderHostToBigEndian(char *pHeader, int nBitType)
42+{ 55+{
43+ if (nBitType == en_is64) 56+ if (nBitType == en_is64 && __BYTE_ORDER == __LITTLE_ENDIAN)
44+ { 57+ {
45+ struct pi_header64 *pHeader64 = (struct pi_header64*)pHeader; 58+ struct pi_header64 *pHeader64 = (struct pi_header64*)pHeader;
46+ 59+
47+ pHeader64->pih_magic = htobe64(pHeader64->pih_magic); 60+ pHeader64->pih_magic = bswap_64(pHeader64->pih_magic);
48+ pHeader64->pih_numwords = htobe64(pHeader64->pih_numwords); 61+ pHeader64->pih_numwords = bswap_64(pHeader64->pih_numwords);
49+ pHeader64->pih_blocklen = htobe16(pHeader64->pih_blocklen); 62+ pHeader64->pih_blocklen = bswap_16(pHeader64->pih_blocklen);
50+ pHeader64->pih_pad = htobe16(pHeader64->pih_pad); 63+ pHeader64->pih_pad = bswap_16(pHeader64->pih_pad);
51+ 64+
52+#if DEBUG 65+#if DEBUG
53+ printf("Header64: magic %x, numwords %x, blocklen %x, pad %x\n", 66+ printf("Header64: magic %x, numwords %x, blocklen %x, pad %x\n",
@@ -55,14 +68,14 @@ index 8f32d14..323ee83 100644
55+ pHeader64->pih_blocklen, pHeader64->pih_pad); 68+ pHeader64->pih_blocklen, pHeader64->pih_pad);
56+#endif 69+#endif
57+ } 70+ }
58+ else if (nBitType == en_is32) 71+ else if (nBitType == en_is32 && __BYTE_ORDER == __LITTLE_ENDIAN)
59+ { 72+ {
60+ struct pi_header *pHeader32 = (struct pi_header*)pHeader; 73+ struct pi_header *pHeader32 = (struct pi_header*)pHeader;
61+ 74+
62+ pHeader32->pih_magic = htobe32(pHeader32->pih_magic); 75+ pHeader32->pih_magic = bswap_32(pHeader32->pih_magic);
63+ pHeader32->pih_numwords = htobe32(pHeader32->pih_numwords); 76+ pHeader32->pih_numwords = bswap_32(pHeader32->pih_numwords);
64+ pHeader32->pih_blocklen = htobe16(pHeader32->pih_blocklen); 77+ pHeader32->pih_blocklen = bswap_16(pHeader32->pih_blocklen);
65+ pHeader32->pih_pad = htobe16(pHeader32->pih_pad); 78+ pHeader32->pih_pad = bswap_16(pHeader32->pih_pad);
66+ 79+
67+#if DEBUG 80+#if DEBUG
68+ printf("Header32: magic %x, numwords %x, blocklen %x, pad %x\n", 81+ printf("Header32: magic %x, numwords %x, blocklen %x, pad %x\n",
@@ -70,7 +83,7 @@ index 8f32d14..323ee83 100644
70+ pHeader32->pih_blocklen, pHeader32->pih_pad); 83+ pHeader32->pih_blocklen, pHeader32->pih_pad);
71+#endif 84+#endif
72+ } 85+ }
73+ else 86+ else if (__BYTE_ORDER == __LITTLE_ENDIAN)
74+ { 87+ {
75+ fprintf(stderr, "Neither 32 or 64: %d\n", nBitType); 88+ fprintf(stderr, "Neither 32 or 64: %d\n", nBitType);
76+ return (-1); 89+ return (-1);
@@ -82,14 +95,14 @@ index 8f32d14..323ee83 100644
82+static int 95+static int
83+IheaderBigEndianToHost(char *pHeader, int nBitType) 96+IheaderBigEndianToHost(char *pHeader, int nBitType)
84+{ 97+{
85+ if (nBitType == en_is64) 98+ if (nBitType == en_is64 && __BYTE_ORDER == __LITTLE_ENDIAN)
86+ { 99+ {
87+ struct pi_header64 *pHeader64 = (struct pi_header64*)pHeader; 100+ struct pi_header64 *pHeader64 = (struct pi_header64*)pHeader;
88+ 101+
89+ pHeader64->pih_magic = be64toh(pHeader64->pih_magic); 102+ pHeader64->pih_magic = bswap_64(pHeader64->pih_magic);
90+ pHeader64->pih_numwords = be64toh(pHeader64->pih_numwords); 103+ pHeader64->pih_numwords = bswap_64(pHeader64->pih_numwords);
91+ pHeader64->pih_blocklen = be16toh(pHeader64->pih_blocklen); 104+ pHeader64->pih_blocklen = bswap_16(pHeader64->pih_blocklen);
92+ pHeader64->pih_pad = be16toh(pHeader64->pih_pad); 105+ pHeader64->pih_pad = bswap_16(pHeader64->pih_pad);
93+ 106+
94+#if DEBUG 107+#if DEBUG
95+ printf("Header64: magic %x, numwords %x, blocklen %x, pad %x\n", 108+ printf("Header64: magic %x, numwords %x, blocklen %x, pad %x\n",
@@ -97,14 +110,14 @@ index 8f32d14..323ee83 100644
97+ pHeader64->pih_blocklen, pHeader64->pih_pad); 110+ pHeader64->pih_blocklen, pHeader64->pih_pad);
98+#endif 111+#endif
99+ } 112+ }
100+ else if (nBitType == en_is32) 113+ else if (nBitType == en_is32 && __BYTE_ORDER == __LITTLE_ENDIAN)
101+ { 114+ {
102+ struct pi_header *pHeader32 = (struct pi_header*)pHeader; 115+ struct pi_header *pHeader32 = (struct pi_header*)pHeader;
103+ 116+
104+ pHeader32->pih_magic = be32toh(pHeader32->pih_magic); 117+ pHeader32->pih_magic = bswap_32(pHeader32->pih_magic);
105+ pHeader32->pih_numwords = be32toh(pHeader32->pih_numwords); 118+ pHeader32->pih_numwords = bswap_32(pHeader32->pih_numwords);
106+ pHeader32->pih_blocklen = be16toh(pHeader32->pih_blocklen); 119+ pHeader32->pih_blocklen = bswap_16(pHeader32->pih_blocklen);
107+ pHeader32->pih_pad = be16toh(pHeader32->pih_pad); 120+ pHeader32->pih_pad = bswap_16(pHeader32->pih_pad);
108+ 121+
109+#if DEBUG 122+#if DEBUG
110+ printf("Header32: magic %x, numwords %x, blocklen %x, pad %x\n", 123+ printf("Header32: magic %x, numwords %x, blocklen %x, pad %x\n",
@@ -112,7 +125,7 @@ index 8f32d14..323ee83 100644
112+ pHeader32->pih_blocklen, pHeader32->pih_pad); 125+ pHeader32->pih_blocklen, pHeader32->pih_pad);
113+#endif 126+#endif
114+ } 127+ }
115+ else 128+ else if (__BYTE_ORDER == __LITTLE_ENDIAN)
116+ { 129+ {
117+ fprintf(stderr, "Neither 32 or 64: %d\n", nBitType); 130+ fprintf(stderr, "Neither 32 or 64: %d\n", nBitType);
118+ return (-1); 131+ return (-1);
@@ -126,27 +139,27 @@ index 8f32d14..323ee83 100644
126+{ 139+{
127+ int i = 0; 140+ int i = 0;
128+ 141+
129+ if (nBitType == en_is64) 142+ if (nBitType == en_is64 && __BYTE_ORDER == __LITTLE_ENDIAN)
130+ { 143+ {
131+ uint64_t *pHwms64 = (uint64_t*)pHwms; 144+ uint64_t *pHwms64 = (uint64_t*)pHwms;
132+ 145+
133+ for (i = 0; i < nLen / sizeof(uint64_t); i++) 146+ for (i = 0; i < nLen / sizeof(uint64_t); i++)
134+ { 147+ {
135+ *pHwms64++ = htobe64(*pHwms64); 148+ *pHwms64++ = bswap_64(*pHwms64);
136+ } 149+ }
137+ 150+
138+ } 151+ }
139+ else if (nBitType == en_is32) 152+ else if (nBitType == en_is32 && __BYTE_ORDER == __LITTLE_ENDIAN)
140+ { 153+ {
141+ uint32_t *pHwms32 = (uint32_t*)pHwms; 154+ uint32_t *pHwms32 = (uint32_t*)pHwms;
142+ 155+
143+ for (i = 0; i < nLen / sizeof(uint32_t); i++) 156+ for (i = 0; i < nLen / sizeof(uint32_t); i++)
144+ { 157+ {
145+ *pHwms32++ = htobe32(*pHwms32); 158+ *pHwms32++ = bswap_32(*pHwms32);
146+ } 159+ }
147+ 160+
148+ } 161+ }
149+ else 162+ else if (__BYTE_ORDER == __LITTLE_ENDIAN)
150+ { 163+ {
151+ fprintf(stderr, "Neither 32 or 64: %d\n", nBitType); 164+ fprintf(stderr, "Neither 32 or 64: %d\n", nBitType);
152+ return (-1); 165+ return (-1);
@@ -170,27 +183,27 @@ index 8f32d14..323ee83 100644
170+{ 183+{
171+ int i = 0; 184+ int i = 0;
172+ 185+
173+ if (nBitType == en_is64) 186+ if (nBitType == en_is64 && __BYTE_ORDER == __LITTLE_ENDIAN)
174+ { 187+ {
175+ uint64_t *pHwms64 = (uint64_t*)pHwms; 188+ uint64_t *pHwms64 = (uint64_t*)pHwms;
176+ 189+
177+ for (i = 0; i < nLen / sizeof(uint64_t); i++) 190+ for (i = 0; i < nLen / sizeof(uint64_t); i++)
178+ { 191+ {
179+ *pHwms64++ = be64toh(*pHwms64); 192+ *pHwms64++ = bswap_64(*pHwms64);
180+ } 193+ }
181+ 194+
182+ } 195+ }
183+ else if (nBitType == en_is32) 196+ else if (nBitType == en_is32 && __BYTE_ORDER == __LITTLE_ENDIAN)
184+ { 197+ {
185+ uint32_t *pHwms32 = (uint32_t*)pHwms; 198+ uint32_t *pHwms32 = (uint32_t*)pHwms;
186+ 199+
187+ for (i = 0; i < nLen / sizeof(uint32_t); i++) 200+ for (i = 0; i < nLen / sizeof(uint32_t); i++)
188+ { 201+ {
189+ *pHwms32++ = be32toh(*pHwms32); 202+ *pHwms32++ = bswap_32(*pHwms32);
190+ } 203+ }
191+ 204+
192+ } 205+ }
193+ else 206+ else if (__BYTE_ORDER == __LITTLE_ENDIAN)
194+ { 207+ {
195+ fprintf(stderr, "Neither 32 or 64: %d\n", nBitType); 208+ fprintf(stderr, "Neither 32 or 64: %d\n", nBitType);
196+ return (-1); 209+ return (-1);
@@ -211,7 +224,7 @@ index 8f32d14..323ee83 100644
211 224
212 static int 225 static int
213 _PWIsBroken64(FILE *ifp) 226 _PWIsBroken64(FILE *ifp)
214@@ -57,6 +236,7 @@ _PWIsBroken64(FILE *ifp) 227@@ -57,6 +239,7 @@ _PWIsBroken64(FILE *ifp)
215 return 0; 228 return 0;
216 } 229 }
217 230
@@ -219,7 +232,7 @@ index 8f32d14..323ee83 100644
219 return (pdesc64.header.pih_magic == PIH_MAGIC); 232 return (pdesc64.header.pih_magic == PIH_MAGIC);
220 } 233 }
221 234
222@@ -149,7 +329,11 @@ PWOpen(prefix, mode) 235@@ -149,7 +332,11 @@ PWOpen(prefix, mode)
223 pdesc.header.pih_blocklen = NUMWORDS; 236 pdesc.header.pih_blocklen = NUMWORDS;
224 pdesc.header.pih_numwords = 0; 237 pdesc.header.pih_numwords = 0;
225 238
@@ -232,7 +245,7 @@ index 8f32d14..323ee83 100644
232 } else 245 } else
233 { 246 {
234 pdesc.flags &= ~PFOR_WRITE; 247 pdesc.flags &= ~PFOR_WRITE;
235@@ -173,6 +357,7 @@ PWOpen(prefix, mode) 248@@ -173,6 +360,7 @@ PWOpen(prefix, mode)
236 return ((PWDICT *) 0); 249 return ((PWDICT *) 0);
237 } 250 }
238 251
@@ -240,7 +253,7 @@ index 8f32d14..323ee83 100644
240 if ((pdesc.header.pih_magic == 0) || (pdesc.header.pih_numwords == 0)) 253 if ((pdesc.header.pih_magic == 0) || (pdesc.header.pih_numwords == 0))
241 { 254 {
242 /* uh-oh. either a broken "64-bit" file or a garbage file. */ 255 /* uh-oh. either a broken "64-bit" file or a garbage file. */
243@@ -195,6 +380,7 @@ PWOpen(prefix, mode) 256@@ -195,6 +383,7 @@ PWOpen(prefix, mode)
244 } 257 }
245 return ((PWDICT *) 0); 258 return ((PWDICT *) 0);
246 } 259 }
@@ -248,7 +261,7 @@ index 8f32d14..323ee83 100644
248 if (pdesc64.header.pih_magic != PIH_MAGIC) 261 if (pdesc64.header.pih_magic != PIH_MAGIC)
249 { 262 {
250 /* nope, not "64-bit" after all */ 263 /* nope, not "64-bit" after all */
251@@ -290,6 +476,7 @@ PWOpen(prefix, mode) 264@@ -290,6 +479,7 @@ PWOpen(prefix, mode)
252 { 265 {
253 pdesc.flags &= ~PFOR_USEHWMS; 266 pdesc.flags &= ~PFOR_USEHWMS;
254 } 267 }
@@ -256,7 +269,7 @@ index 8f32d14..323ee83 100644
256 for (i = 0; i < sizeof(pdesc.hwms) / sizeof(pdesc.hwms[0]); i++) 269 for (i = 0; i < sizeof(pdesc.hwms) / sizeof(pdesc.hwms[0]); i++)
257 { 270 {
258 pdesc.hwms[i] = pdesc64.hwms[i]; 271 pdesc.hwms[i] = pdesc64.hwms[i];
259@@ -299,6 +486,7 @@ PWOpen(prefix, mode) 272@@ -299,6 +489,7 @@ PWOpen(prefix, mode)
260 { 273 {
261 pdesc.flags &= ~PFOR_USEHWMS; 274 pdesc.flags &= ~PFOR_USEHWMS;
262 } 275 }
@@ -264,7 +277,7 @@ index 8f32d14..323ee83 100644
264 #if DEBUG 277 #if DEBUG
265 for (i=1; i<=0xff; i++) 278 for (i=1; i<=0xff; i++)
266 { 279 {
267@@ -332,7 +520,11 @@ PWClose(pwp) 280@@ -332,7 +523,11 @@ PWClose(pwp)
268 return (-1); 281 return (-1);
269 } 282 }
270 283
@@ -277,7 +290,7 @@ index 8f32d14..323ee83 100644
277 { 290 {
278 fprintf(stderr, "index magic fwrite failed\n"); 291 fprintf(stderr, "index magic fwrite failed\n");
279 return (-1); 292 return (-1);
280@@ -351,7 +543,12 @@ PWClose(pwp) 293@@ -351,7 +546,12 @@ PWClose(pwp)
281 printf("hwm[%02x] = %d\n", i, pwp->hwms[i]); 294 printf("hwm[%02x] = %d\n", i, pwp->hwms[i]);
282 #endif 295 #endif
283 } 296 }
@@ -291,32 +304,29 @@ index 8f32d14..323ee83 100644
291 } 304 }
292 } 305 }
293 306
294@@ -405,7 +602,8 @@ PutPW(pwp, string) 307@@ -405,7 +605,8 @@ PutPW(pwp, string)
295 308
296 datum = (uint32_t) ftell(pwp->dfp); 309 datum = (uint32_t) ftell(pwp->dfp);
297 310
298- fwrite((char *) &datum, sizeof(datum), 1, pwp->ifp); 311- fwrite((char *) &datum, sizeof(datum), 1, pwp->ifp);
299+ uint32_t tmpdatum = htobe32(datum); 312+ uint32_t tmpdatum = (__BYTE_ORDER == __LITTLE_ENDIAN) ? bswap_32(datum) : datum;
300+ fwrite((char *) &tmpdatum, sizeof(tmpdatum), 1, pwp->ifp); 313+ fwrite((char *) &tmpdatum, sizeof(tmpdatum), 1, pwp->ifp);
301 314
302 fputs(pwp->data_put[0], pwp->dfp); 315 fputs(pwp->data_put[0], pwp->dfp);
303 putc(0, pwp->dfp); 316 putc(0, pwp->dfp);
304@@ -473,6 +671,7 @@ GetPW(pwp, number) 317@@ -473,6 +674,7 @@ GetPW(pwp, number)
305 perror("(index fread failed)"); 318 perror("(index fread failed)");
306 return ((char *) 0); 319 return ((char *) 0);
307 } 320 }
308+ datum64 = be64toh(datum64); 321+ datum64 = (__BYTE_ORDER == __LITTLE_ENDIAN) ? bswap_64(datum64) : datum64;
309 datum = datum64; 322 datum = datum64;
310 } else { 323 } else {
311 if (fseek(pwp->ifp, sizeof(struct pi_header) + (thisblock * sizeof(uint32_t)), 0)) 324 if (fseek(pwp->ifp, sizeof(struct pi_header) + (thisblock * sizeof(uint32_t)), 0))
312@@ -486,6 +685,7 @@ GetPW(pwp, number) 325@@ -486,6 +688,7 @@ GetPW(pwp, number)
313 perror("(index fread failed)"); 326 perror("(index fread failed)");
314 return ((char *) 0); 327 return ((char *) 0);
315 } 328 }
316+ datum = be32toh(datum); 329+ datum = (__BYTE_ORDER == __LITTLE_ENDIAN) ? bswap_32(datum) : datum;
317 } 330 }
318 331
319 int r = 1; 332 int r = 1;
320--
3211.7.10.4
322