0233e9
From 5c9f96799961818944d43b22c241cc56c215c2e4 Mon Sep 17 00:00:00 2001
0233e9
From: Remi Collet <remi@php.net>
0233e9
Date: Tue, 10 Jun 2014 14:13:14 +0200
0233e9
Subject: [PATCH] Fixed Bug #67411 	fileinfo: cdf_check_stream_offset
0233e9
 insufficient boundary check
0233e9
0233e9
Upstream:
0233e9
https://github.com/file/file/commit/36fadd29849b8087af9f4586f89dbf74ea45be67
0233e9
---
0233e9
 ext/fileinfo/libmagic/cdf.c | 6 ++++--
0233e9
 1 file changed, 4 insertions(+), 2 deletions(-)
0233e9
0233e9
diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c
0233e9
index 16649f1..c9a5d50 100644
0233e9
--- a/src/cdf.c
0233e9
+++ b/src/cdf.c
83d9a8
@@ -267,13 +267,15 @@ cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h,
0233e9
 {
0233e9
 	const char *b = (const char *)sst->sst_tab;
0233e9
 	const char *e = ((const char *)p) + tail;
0233e9
+	size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ?
0233e9
+	    CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h);
0233e9
 	(void)&line;
0233e9
-	if (e >= b && (size_t)(e - b) < CDF_SEC_SIZE(h) * sst->sst_len)
0233e9
+	if (e >= b && (size_t)(e - b) <= ss * sst->sst_len)
0233e9
 		return 0;
0233e9
 	DPRINTF(("%d: offset begin %p end %p %" SIZE_T_FORMAT "u"
0233e9
 	    " >= %" SIZE_T_FORMAT "u [%" SIZE_T_FORMAT "u %"
0233e9
 	    SIZE_T_FORMAT "u]\n", line, b, e, (size_t)(e - b),
0233e9
-	    CDF_SEC_SIZE(h) * sst->sst_len, CDF_SEC_SIZE(h), sst->sst_len));
0233e9
+	    ss * sst->sst_len, ss, sst->sst_len));
0233e9
 	errno = EFTYPE;
0233e9
 	return -1;
0233e9
 }
0233e9
-- 
0233e9
1.9.2
0233e9