d2399a
From 4fcb9a9d1b1063a65fbeb27395de4979c75bd962 Mon Sep 17 00:00:00 2001
d2399a
From: Remi Collet <remi@php.net>
d2399a
Date: Tue, 3 Jun 2014 11:05:00 +0200
d2399a
Subject: [PATCH] Fix bug #67326	fileinfo: cdf_read_short_sector insufficient
d2399a
 boundary check
d2399a
d2399a
Upstream fix https://github.com/file/file/commit/6d209c1c489457397a5763bca4b28e43aac90391.patch
d2399a
Only revelant part applied
d2399a
---
d2399a
 ext/fileinfo/libmagic/cdf.c | 4 ++--
d2399a
 1 file changed, 2 insertions(+), 2 deletions(-)
d2399a
d2399a
diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c
d2399a
index 4712e84..16649f1 100644
d2399a
--- a/ext/fileinfo/libmagic/cdf.c
d2399a
+++ b/ext/fileinfo/libmagic/cdf.c
d2399a
@@ -367,10 +367,10 @@ cdf_read_short_sector(const cdf_stream_t *sst, void *buf, size_t offs,
d2399a
 	size_t ss = CDF_SHORT_SEC_SIZE(h);
d2399a
 	size_t pos = CDF_SHORT_SEC_POS(h, id);
d2399a
 	assert(ss == len);
d2399a
-	if (pos > CDF_SEC_SIZE(h) * sst->sst_len) {
d2399a
+	if (pos + len > CDF_SEC_SIZE(h) * sst->sst_len) {
d2399a
 		DPRINTF(("Out of bounds read %" SIZE_T_FORMAT "u > %"
d2399a
 		    SIZE_T_FORMAT "u\n",
d2399a
-		    pos, CDF_SEC_SIZE(h) * sst->sst_len));
d2399a
+		    pos + len, CDF_SEC_SIZE(h) * sst->sst_len));
d2399a
 		return -1;
d2399a
 	}
d2399a
 	(void)memcpy(((char *)buf) + offs,
d2399a
-- 
d2399a
1.9.2
d2399a