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