ports/mail/cyrus-imapd24/files/patch-CVE-2015-8077

40 lines
1.2 KiB
Text

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
--- imap/index.c.orig 2015-07-06 03:38:29 UTC
+++ imap/index.c
@@ -2712,7 +2712,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];
@@ -2849,7 +2850,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;
}
@@ -2861,10 +2862,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);
}
}