Package: cyrus-imapd-2.4 / 2.4.17+nocaldav-0+deb8u2

CVE-2015-8077.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From 745e161c834f1eb6d62fc14477f51dae799e1e08 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


--- cyrus-imapd-2.4.orig/imap/index.c
+++ cyrus-imapd-2.4/imap/index.c
@@ -2711,7 +2711,8 @@ int index_urlfetch(struct index_state *s
     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];
@@ -2848,7 +2849,7 @@ int index_urlfetch(struct index_state *s
         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;
     }
 
@@ -2860,10 +2861,10 @@ int index_urlfetch(struct index_state *s
 
 	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);
 	}
     }