b74969
From 68ce2d0ea6da79b12a365e375e1c2ce882c77480 Mon Sep 17 00:00:00 2001
b74969
From: Stanislav Malyshev <stas@php.net>
b74969
Date: Mon, 26 May 2014 17:50:14 -0700
b74969
Subject: [PATCH] Fix bug #67328 (fileinfo: numerous file_printf calls
b74969
 resulting in performance degradation)
b74969
b74969
Upstream patch: https://github.com/file/file/commit/b8acc83781d5a24cc5101e525d15efe0482c280d
b74969
---
b74969
 ext/fileinfo/libmagic/cdf.c | 16 ++++------------
b74969
 1 file changed, 4 insertions(+), 12 deletions(-)
b74969
b74969
diff --git a/ext/fileinfo/libmagic/cdf.c b/ext/fileinfo/libmagic/cdf.c
b74969
index dd7177e..8dacd2f 100644
b74969
--- a/ext/fileinfo/libmagic/cdf.c
b74969
+++ b/ext/fileinfo/libmagic/cdf.c
b74969
@@ -942,7 +942,7 @@ int
b74969
 cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
b74969
     cdf_summary_info_header_t *ssi, cdf_property_info_t **info, size_t *count)
b74969
 {
b74969
-	size_t i, maxcount;
b74969
+	size_t maxcount;
b74969
 	const cdf_summary_info_header_t *si =
b74969
 	    CAST(const cdf_summary_info_header_t *, sst->sst_tab);
b74969
 	const cdf_section_declaration_t *sd =
b74969
@@ -957,21 +957,13 @@ cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h,
b74969
 	ssi->si_os = CDF_TOLE2(si->si_os);
b74969
 	ssi->si_class = si->si_class;
b74969
 	cdf_swap_class(&ssi->si_class);
b74969
-	ssi->si_count = CDF_TOLE2(si->si_count);
b74969
+	ssi->si_count = CDF_TOLE4(si->si_count);
b74969
 	*count = 0;
b74969
 	maxcount = 0;
b74969
 	*info = NULL;
b74969
-	for (i = 0; i < CDF_TOLE4(si->si_count); i++) {
b74969
-		if (i >= CDF_LOOP_LIMIT) {
b74969
-			DPRINTF(("Unpack summary info loop limit"));
b74969
-			errno = EFTYPE;
b74969
-			return -1;
b74969
-		}
b74969
-		if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset),
b74969
-		    info, count, &maxcount) == -1) {
b74969
+	if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset), info,
b74969
+		count, &maxcount) == -1) 
b74969
 			return -1;
b74969
-		}
b74969
-	}
b74969
 	return 0;
b74969
 }
b74969
 
b74969
-- 
b74969
1.9.2
b74969