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