]> granicus.if.org Git - php/commitdiff
Fixed bug #66307 Fileinfo crashes with powerpoint files
authorAnatol Belski <ab@php.net>
Thu, 24 Apr 2014 17:30:34 +0000 (19:30 +0200)
committerStanislav Malyshev <stas@php.net>
Fri, 18 Jul 2014 22:48:18 +0000 (15:48 -0700)
Conflicts:
ext/fileinfo/libmagic/readcdf.c
ext/fileinfo/tests/finfo_file_002.phpt

ext/fileinfo/libmagic/readcdf.c
ext/fileinfo/tests/finfo_file_002.phpt
ext/fileinfo/tests/resources/test.ppt [new file with mode: 0644]

index 0c28ffbfa81e289125ed806b2603e95bbe9f6cce..dc6bcf094bdd547d70d222f4718d9f1c58121596 100644 (file)
@@ -56,6 +56,8 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
         const char *s;
         int len;
 
+       memset(&ts, 0, sizeof(ts));
+
         for (i = 0; i < count; i++) {
                 cdf_print_property_name(buf, sizeof(buf), info[i].pi_id);
                 switch (info[i].pi_type) {
@@ -142,10 +144,11 @@ cdf_file_property_info(struct magic_set *ms, const cdf_property_info_t *info,
                                                 return -1;
                                 } else {
                                         char *c, *ec;
+                                        const time_t sec = ts.tv_sec;
                                         if (cdf_timestamp_to_timespec(&ts, tp) == -1) {
                                                                                        return -1;
                                                                                }
-                                        c = cdf_ctime(&ts.tv_sec);
+                                        c = cdf_ctime(&sec);
                                         if ((ec = strchr(c, '\n')) != NULL)
                                                 *ec = '\0';
 
index 3593233c3996c3381b80e1cc26de642333116e0a..c3f8388659399cce265be98408fd5075aa1f0acc 100644 (file)
@@ -18,7 +18,7 @@ ksort($results);
 var_dump($results);
 ?>
 --EXPECTF--
-array(7) {
+array(8) {
   ["%s/resources/dir.zip"]=>
   string(15) "application/zip"
   ["%s/resources/test.awk"]=>
@@ -33,4 +33,6 @@ array(7) {
   string(15) "application/pdf"
   ["%s/resources/test.png"]=>
   string(9) "image/png"
+  ["%s/resources/test.ppt"]=>
+  string(29) "application/vnd.ms-powerpoint"
 }
diff --git a/ext/fileinfo/tests/resources/test.ppt b/ext/fileinfo/tests/resources/test.ppt
new file mode 100644 (file)
index 0000000..713004c
Binary files /dev/null and b/ext/fileinfo/tests/resources/test.ppt differ