--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/curl/patches/006-CVE-2013-0249.patch Wed Feb 06 07:41:13 2013 -0800
@@ -0,0 +1,69 @@
+From ee45a34907ffeb5fd95b0513040d8491d565b663 Mon Sep 17 00:00:00 2001
+From: Eldar Zaitov <[email protected]>
+Date: Wed, 30 Jan 2013 23:22:27 +0100
+Subject: [PATCH] Curl_sasl_create_digest_md5_message: fix buffer overflow
+
+When negotiating SASL DIGEST-MD5 authentication, the function
+Curl_sasl_create_digest_md5_message() uses the data provided from the
+server without doing the proper length checks and that data is then
+appended to a local fixed-size buffer on the stack.
+
+This vulnerability can be exploited by someone who is in control of a
+server that a libcurl based program is accessing with POP3, SMTP or
+IMAP. For applications that accept user provided URLs, it is also
+thinkable that a malicious user would feed an application with a URL to
+a server hosting code targetting this flaw.
+
+Bug: http://curl.haxx.se/docs/adv_20130206.html
+
+(Note that these changes need to be applied to similar code in
+ .../lib/smtp.c for curl version 7.26.0)
+
+--- lib/smtp.c.orig 2013-02-05 08:06:03.823585006 -0800
++++ lib/smtp.c 2013-02-05 08:12:38.007595100 -0800
[email protected]@ -879,7 +879,7 @@
+ char cnonce[] = "12345678"; /* will be changed */
+ char method[] = "AUTHENTICATE";
+ char qop[] = "auth";
+- char uri[128] = "smtp/";
++ char uri[128];
+ char response[512];
+
+ (void)instate; /* no use for this yet */
[email protected]@ -963,8 +963,8 @@
+ for(i = 0; i < MD5_DIGEST_LEN; i++)
+ snprintf(&HA1_hex[2 * i], 3, "%02x", digest[i]);
+
+- /* Orepare URL string, append realm to the protocol */
+- strcat(uri, realm);
++ /* Prepare URL string, append realm to the protocol */
++ snprintf(uri, sizeof(uri), "smtp/%s", realm);
+
+ /* Calculate H(A2) */
+ ctxt = Curl_MD5_init(Curl_DIGEST_MD5);
[email protected]@ -1008,20 +1008,11 @@
+ for(i = 0; i < MD5_DIGEST_LEN; i++)
+ snprintf(&resp_hash_hex[2 * i], 3, "%02x", digest[i]);
+
+- strcpy(response, "username=\"");
+- strcat(response, conn->user);
+- strcat(response, "\",realm=\"");
+- strcat(response, realm);
+- strcat(response, "\",nonce=\"");
+- strcat(response, nonce);
+- strcat(response, "\",cnonce=\"");
+- strcat(response, cnonce);
+- strcat(response, "\",nc=");
+- strcat(response, nonceCount);
+- strcat(response, ",digest-uri=\"");
+- strcat(response, uri);
+- strcat(response, "\",response=");
+- strcat(response, resp_hash_hex);
++ snprintf(response, sizeof(response),
++ "username=\"%s\",realm=\"%s\",nonce=\"%s\","
++ "cnonce=\"%s\",nc=\"%s\",digest-uri=\"%s\",response=%s",
++ conn->user, realm, nonce,
++ cnonce, nonceCount, uri, resp_hash_hex);
+
+ /* Encode it to base64 and send it */
+ result = Curl_base64_encode(data, response, 0, &rplyb64, &len);