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