File cyrus-imapd-2.4.18-CVE-2015-8077.patch of Package cyrus-imapd

From 538359e5a7c978e2f27c80124c8bd1282c7661a9 Mon Sep 17 00:00:00 2001
From: ellie timoney <ellie@fastmail.com>
Date: Mon, 26 Oct 2015 16:15:40 +1100
Subject: urlfetch: protect against overflow in range checks


diff --git a/imap/index.c b/imap/index.c
index 43dfe16..566a983 100644
--- a/imap/index.c
+++ b/imap/index.c
@@ -2712,7 +2712,8 @@ int index_urlfetch(struct index_state *state, uint32_t msgno,
     int fetchmime = 0, domain = DOMAIN_7BIT;
     unsigned size;
     int32_t skip = 0;
-    int n, r = 0;
+    unsigned long n;
+    int r = 0;
     char *decbuf = NULL;
     struct mailbox *mailbox = state->mailbox;
     struct index_map *im = &state->map[msgno-1];
@@ -2849,7 +2850,7 @@ int index_urlfetch(struct index_state *state, uint32_t msgno,
         start_octet = size;
         n = 0;
     }
-    else if (start_octet + n > size) {
+    else if (start_octet + n < start_octet || start_octet + n > size) {
         n = size - start_octet;
     }
 
@@ -2861,10 +2862,10 @@ int index_urlfetch(struct index_state *state, uint32_t msgno,
 
 	if (domain == DOMAIN_BINARY) {
 	    /* Write size of literal8 */
-	    prot_printf(pout, " ~{%u}\r\n", n);
+            prot_printf(pout, " ~{%lu}\r\n", n);
 	} else {
 	    /* Write size of literal */
-	    prot_printf(pout, " {%u}\r\n", n);
+            prot_printf(pout, " {%lu}\r\n", n);
 	}
     }
 
-- 
cgit v0.10.2

openSUSE Build Service is sponsored by