Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(984)

Unified Diff: third_party/libxslt/libexslt/crypto.c

Issue 1193533007: Upgrade to libxml 2.9.2 and libxslt 1.1.28 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove suppressions, have landed in blink now Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/libxslt/libexslt/crypto.c
diff --git a/third_party/libxslt/libexslt/crypto.c b/third_party/libxslt/libexslt/crypto.c
index e2700d6b5f23557dc8b78957743ef9f06337a44a..6aa9dd2540fa1aec58c3cc8b746bb0f07275df37 100644
--- a/third_party/libxslt/libexslt/crypto.c
+++ b/third_party/libxslt/libexslt/crypto.c
@@ -27,7 +27,7 @@
#define MD5_DIGEST_LENGTH 16
#define SHA1_DIGEST_LENGTH 20
-/* gcrypt rc4 can do 256 bit keys, but cryptoapi limit
+/* gcrypt rc4 can do 256 bit keys, but cryptoapi limit
seems to be 128 for the default provider */
#define RC4_KEY_LENGTH 128
@@ -48,7 +48,7 @@
* @hex: buffer to store hex version of blob
* @hexlen: length of buffer to store hex version of blob
*
- * Helper function which encodes a binary blob as hex.
+ * Helper function which encodes a binary blob as hex.
*/
static void
exsltCryptoBin2Hex (const unsigned char *bin, int binlen,
@@ -357,7 +357,7 @@ exsltCryptoGcryptInit (void) {
* @msglen: length of text to be hashed
* @dest: buffer to place hash result
*
- * Helper function which hashes a message using MD4, MD5, or SHA1.
+ * Helper function which hashes a message using MD4, MD5, or SHA1.
* using gcrypt
*/
static void
@@ -457,7 +457,8 @@ exsltCryptoGcryptRc4Decrypt (xmlXPathParserContextPtr ctxt,
* @ctxt: an XPath parser context
* @nargs: the number of arguments
*
- * Helper function which checks for and returns first string argument and its length
+ * Helper function which checks for and returns first string argument and its
+ * length in bytes.
*/
static int
exsltCryptoPopString (xmlXPathParserContextPtr ctxt, int nargs,
@@ -471,7 +472,7 @@ exsltCryptoPopString (xmlXPathParserContextPtr ctxt, int nargs,
}
*str = xmlXPathPopString (ctxt);
- str_len = xmlUTF8Strlen (*str);
+ str_len = xmlStrlen (*str);
if (str_len == 0) {
xmlXPathReturnEmptyString (ctxt);
@@ -591,7 +592,7 @@ exsltCryptoSha1Function (xmlXPathParserContextPtr ctxt, int nargs) {
static void
exsltCryptoRc4EncryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
- int key_len = 0, key_size = 0;
+ int key_len = 0;
int str_len = 0, bin_len = 0, hex_len = 0;
xmlChar *key = NULL, *str = NULL, *padkey = NULL;
xmlChar *bin = NULL, *hex = NULL;
@@ -604,7 +605,7 @@ exsltCryptoRc4EncryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
tctxt = xsltXPathGetTransformContext(ctxt);
str = xmlXPathPopString (ctxt);
- str_len = xmlUTF8Strlen (str);
+ str_len = xmlStrlen (str);
if (str_len == 0) {
xmlXPathReturnEmptyString (ctxt);
@@ -613,7 +614,7 @@ exsltCryptoRc4EncryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
}
key = xmlXPathPopString (ctxt);
- key_len = xmlUTF8Strlen (key);
+ key_len = xmlStrlen (key);
if (key_len == 0) {
xmlXPathReturnEmptyString (ctxt);
@@ -632,15 +633,14 @@ exsltCryptoRc4EncryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
}
memset(padkey, 0, RC4_KEY_LENGTH + 1);
- key_size = xmlUTF8Strsize (key, key_len);
- if ((key_size > RC4_KEY_LENGTH) || (key_size < 0)) {
+ if ((key_len > RC4_KEY_LENGTH) || (key_len < 0)) {
xsltTransformError(tctxt, NULL, tctxt->inst,
"exsltCryptoRc4EncryptFunction: key size too long or key broken\n");
tctxt->state = XSLT_STATE_STOPPED;
xmlXPathReturnEmptyString (ctxt);
goto done;
}
- memcpy (padkey, key, key_size);
+ memcpy (padkey, key, key_len);
/* encrypt it */
bin_len = str_len;
@@ -689,7 +689,7 @@ done:
static void
exsltCryptoRc4DecryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
- int key_len = 0, key_size = 0;
+ int key_len = 0;
int str_len = 0, bin_len = 0, ret_len = 0;
xmlChar *key = NULL, *str = NULL, *padkey = NULL, *bin =
NULL, *ret = NULL;
@@ -702,7 +702,7 @@ exsltCryptoRc4DecryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
tctxt = xsltXPathGetTransformContext(ctxt);
str = xmlXPathPopString (ctxt);
- str_len = xmlUTF8Strlen (str);
+ str_len = xmlStrlen (str);
if (str_len == 0) {
xmlXPathReturnEmptyString (ctxt);
@@ -711,7 +711,7 @@ exsltCryptoRc4DecryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
}
key = xmlXPathPopString (ctxt);
- key_len = xmlUTF8Strlen (key);
+ key_len = xmlStrlen (key);
if (key_len == 0) {
xmlXPathReturnEmptyString (ctxt);
@@ -729,15 +729,14 @@ exsltCryptoRc4DecryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
goto done;
}
memset(padkey, 0, RC4_KEY_LENGTH + 1);
- key_size = xmlUTF8Strsize (key, key_len);
- if ((key_size > RC4_KEY_LENGTH) || (key_size < 0)) {
+ if ((key_len > RC4_KEY_LENGTH) || (key_len < 0)) {
xsltTransformError(tctxt, NULL, tctxt->inst,
"exsltCryptoRc4EncryptFunction: key size too long or key broken\n");
tctxt->state = XSLT_STATE_STOPPED;
xmlXPathReturnEmptyString (ctxt);
goto done;
}
- memcpy (padkey, key, key_size);
+ memcpy (padkey, key, key_len);
/* decode hex to binary */
bin_len = str_len;
@@ -752,7 +751,7 @@ exsltCryptoRc4DecryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
ret_len = exsltCryptoHex2Bin (str, str_len, bin, bin_len);
/* decrypt the binary blob */
- ret = xmlMallocAtomic (ret_len);
+ ret = xmlMallocAtomic (ret_len + 1);
if (ret == NULL) {
xsltTransformError(tctxt, NULL, tctxt->inst,
"exsltCryptoRc4EncryptFunction: Failed to allocate result\n");
@@ -761,6 +760,7 @@ exsltCryptoRc4DecryptFunction (xmlXPathParserContextPtr ctxt, int nargs) {
goto done;
}
PLATFORM_RC4_DECRYPT (ctxt, padkey, bin, ret_len, ret, ret_len);
+ ret[ret_len] = 0;
xmlXPathReturnString (ctxt, ret);

Powered by Google App Engine
This is Rietveld 408576698