1 |
eva 08/07/31 20:47:41 |
2 |
|
3 |
Added: libxslt-1.1.24-exslt_crypt.patch |
4 |
Log: |
5 |
bump to r1. Apply patch from bug #232172. |
6 |
(Portage version: 2.2_rc3/cvs/Linux 2.6.24-gentoo-r8-mactel x86_64, RepoMan options: --force) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 dev-libs/libxslt/files/libxslt-1.1.24-exslt_crypt.patch |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-libs/libxslt/files/libxslt-1.1.24-exslt_crypt.patch?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-libs/libxslt/files/libxslt-1.1.24-exslt_crypt.patch?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: libxslt-1.1.24-exslt_crypt.patch |
15 |
=================================================================== |
16 |
Index: libexslt/crypto.c |
17 |
=================================================================== |
18 |
--- libexslt/crypto.c (revision 1479) |
19 |
+++ libexslt/crypto.c (working copy) |
20 |
@@ -595,11 +595,13 @@ exsltCryptoRc4EncryptFunction (xmlXPathP |
21 |
int str_len = 0, bin_len = 0, hex_len = 0; |
22 |
xmlChar *key = NULL, *str = NULL, *padkey = NULL; |
23 |
xmlChar *bin = NULL, *hex = NULL; |
24 |
+ xsltTransformContextPtr tctxt = NULL; |
25 |
|
26 |
- if ((nargs < 1) || (nargs > 3)) { |
27 |
+ if (nargs != 2) { |
28 |
xmlXPathSetArityError (ctxt); |
29 |
return; |
30 |
} |
31 |
+ tctxt = xsltXPathGetTransformContext(ctxt); |
32 |
|
33 |
str = xmlXPathPopString (ctxt); |
34 |
str_len = xmlUTF8Strlen (str); |
35 |
@@ -611,7 +613,7 @@ exsltCryptoRc4EncryptFunction (xmlXPathP |
36 |
} |
37 |
|
38 |
key = xmlXPathPopString (ctxt); |
39 |
- key_len = xmlUTF8Strlen (str); |
40 |
+ key_len = xmlUTF8Strlen (key); |
41 |
|
42 |
if (key_len == 0) { |
43 |
xmlXPathReturnEmptyString (ctxt); |
44 |
@@ -620,15 +622,33 @@ exsltCryptoRc4EncryptFunction (xmlXPathP |
45 |
return; |
46 |
} |
47 |
|
48 |
- padkey = xmlMallocAtomic (RC4_KEY_LENGTH); |
49 |
+ padkey = xmlMallocAtomic (RC4_KEY_LENGTH + 1); |
50 |
+ if (padkey == NULL) { |
51 |
+ xsltTransformError(tctxt, NULL, tctxt->inst, |
52 |
+ "exsltCryptoRc4EncryptFunction: Failed to allocate padkey\n"); |
53 |
+ tctxt->state = XSLT_STATE_STOPPED; |
54 |
+ xmlXPathReturnEmptyString (ctxt); |
55 |
+ goto done; |
56 |
+ } |
57 |
+ memset(padkey, 0, RC4_KEY_LENGTH + 1); |
58 |
+ |
59 |
key_size = xmlUTF8Strsize (key, key_len); |
60 |
+ if ((key_size > RC4_KEY_LENGTH) || (key_size < 0)) { |
61 |
+ xsltTransformError(tctxt, NULL, tctxt->inst, |
62 |
+ "exsltCryptoRc4EncryptFunction: key size too long or key broken\n"); |
63 |
+ tctxt->state = XSLT_STATE_STOPPED; |
64 |
+ xmlXPathReturnEmptyString (ctxt); |
65 |
+ goto done; |
66 |
+ } |
67 |
memcpy (padkey, key, key_size); |
68 |
- memset (padkey + key_size, '\0', sizeof (padkey)); |
69 |
|
70 |
/* encrypt it */ |
71 |
bin_len = str_len; |
72 |
bin = xmlStrdup (str); |
73 |
if (bin == NULL) { |
74 |
+ xsltTransformError(tctxt, NULL, tctxt->inst, |
75 |
+ "exsltCryptoRc4EncryptFunction: Failed to allocate string\n"); |
76 |
+ tctxt->state = XSLT_STATE_STOPPED; |
77 |
xmlXPathReturnEmptyString (ctxt); |
78 |
goto done; |
79 |
} |
80 |
@@ -638,6 +658,9 @@ exsltCryptoRc4EncryptFunction (xmlXPathP |
81 |
hex_len = str_len * 2 + 1; |
82 |
hex = xmlMallocAtomic (hex_len); |
83 |
if (hex == NULL) { |
84 |
+ xsltTransformError(tctxt, NULL, tctxt->inst, |
85 |
+ "exsltCryptoRc4EncryptFunction: Failed to allocate result\n"); |
86 |
+ tctxt->state = XSLT_STATE_STOPPED; |
87 |
xmlXPathReturnEmptyString (ctxt); |
88 |
goto done; |
89 |
} |
90 |
@@ -670,11 +693,13 @@ exsltCryptoRc4DecryptFunction (xmlXPathP |
91 |
int str_len = 0, bin_len = 0, ret_len = 0; |
92 |
xmlChar *key = NULL, *str = NULL, *padkey = NULL, *bin = |
93 |
NULL, *ret = NULL; |
94 |
+ xsltTransformContextPtr tctxt = NULL; |
95 |
|
96 |
- if ((nargs < 1) || (nargs > 3)) { |
97 |
+ if (nargs != 2) { |
98 |
xmlXPathSetArityError (ctxt); |
99 |
return; |
100 |
} |
101 |
+ tctxt = xsltXPathGetTransformContext(ctxt); |
102 |
|
103 |
str = xmlXPathPopString (ctxt); |
104 |
str_len = xmlUTF8Strlen (str); |
105 |
@@ -686,7 +711,7 @@ exsltCryptoRc4DecryptFunction (xmlXPathP |
106 |
} |
107 |
|
108 |
key = xmlXPathPopString (ctxt); |
109 |
- key_len = xmlUTF8Strlen (str); |
110 |
+ key_len = xmlUTF8Strlen (key); |
111 |
|
112 |
if (key_len == 0) { |
113 |
xmlXPathReturnEmptyString (ctxt); |
114 |
@@ -695,22 +720,51 @@ exsltCryptoRc4DecryptFunction (xmlXPathP |
115 |
return; |
116 |
} |
117 |
|
118 |
- padkey = xmlMallocAtomic (RC4_KEY_LENGTH); |
119 |
+ padkey = xmlMallocAtomic (RC4_KEY_LENGTH + 1); |
120 |
+ if (padkey == NULL) { |
121 |
+ xsltTransformError(tctxt, NULL, tctxt->inst, |
122 |
+ "exsltCryptoRc4EncryptFunction: Failed to allocate padkey\n"); |
123 |
+ tctxt->state = XSLT_STATE_STOPPED; |
124 |
+ xmlXPathReturnEmptyString (ctxt); |
125 |
+ goto done; |
126 |
+ } |
127 |
+ memset(padkey, 0, RC4_KEY_LENGTH + 1); |
128 |
key_size = xmlUTF8Strsize (key, key_len); |
129 |
+ if ((key_size > RC4_KEY_LENGTH) || (key_size < 0)) { |
130 |
+ xsltTransformError(tctxt, NULL, tctxt->inst, |
131 |
+ "exsltCryptoRc4EncryptFunction: key size too long or key broken\n"); |
132 |
+ tctxt->state = XSLT_STATE_STOPPED; |
133 |
+ xmlXPathReturnEmptyString (ctxt); |
134 |
+ goto done; |
135 |
+ } |
136 |
memcpy (padkey, key, key_size); |
137 |
- memset (padkey + key_size, '\0', sizeof (padkey)); |
138 |
|
139 |
/* decode hex to binary */ |
140 |
bin_len = str_len; |
141 |
bin = xmlMallocAtomic (bin_len); |
142 |
+ if (bin == NULL) { |
143 |
+ xsltTransformError(tctxt, NULL, tctxt->inst, |
144 |
+ "exsltCryptoRc4EncryptFunction: Failed to allocate string\n"); |
145 |
+ tctxt->state = XSLT_STATE_STOPPED; |
146 |
+ xmlXPathReturnEmptyString (ctxt); |
147 |
+ goto done; |
148 |
+ } |
149 |
ret_len = exsltCryptoHex2Bin (str, str_len, bin, bin_len); |
150 |
|
151 |
/* decrypt the binary blob */ |
152 |
ret = xmlMallocAtomic (ret_len); |
153 |
+ if (ret == NULL) { |
154 |
+ xsltTransformError(tctxt, NULL, tctxt->inst, |
155 |
+ "exsltCryptoRc4EncryptFunction: Failed to allocate result\n"); |
156 |
+ tctxt->state = XSLT_STATE_STOPPED; |
157 |
+ xmlXPathReturnEmptyString (ctxt); |
158 |
+ goto done; |
159 |
+ } |
160 |
PLATFORM_RC4_DECRYPT (ctxt, padkey, bin, ret_len, ret, ret_len); |
161 |
|
162 |
xmlXPathReturnString (ctxt, ret); |
163 |
|
164 |
+done: |
165 |
if (key != NULL) |
166 |
xmlFree (key); |
167 |
if (str != NULL) |