summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-06-29 17:47:21 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2020-06-29 17:47:21 +0200
commit43b5d5834197bef731a06f8ea025550df08c3fd1 (patch)
tree06258ef35c8745a0896295bd6764f08c514b06fd
parentaca621cf926cf86fd186395d3877fc63b65f3d16 (diff)
parentdfac28f8d87c14e2f9fd3427a7c87be1239f6e6a (diff)
downloadphp-git-43b5d5834197bef731a06f8ea025550df08c3fd1.tar.gz
Merge branch 'PHP-7.4'
* PHP-7.4: Fix #79756: finfo_file crash (FILEINFO_MIME)
-rw-r--r--ext/fileinfo/tests/bug79756.phpt16
-rw-r--r--ext/fileinfo/tests/bug79756.xlsbin0 -> 10752 bytes
-rw-r--r--main/reentrancy.c14
3 files changed, 26 insertions, 4 deletions
diff --git a/ext/fileinfo/tests/bug79756.phpt b/ext/fileinfo/tests/bug79756.phpt
new file mode 100644
index 0000000000..4aeeb2a266
--- /dev/null
+++ b/ext/fileinfo/tests/bug79756.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #79756 (finfo_file crash (FILEINFO_MIME))
+--SKIPIF--
+<?php
+if (!extension_loaded('fileinfo')) die('skip fileinfo extension not available');
+?>
+--FILE--
+<?php
+$filename = __DIR__ . '/bug79756.xls';
+$finfo = finfo_open(FILEINFO_MIME);
+$mime = finfo_file($finfo, $filename);
+finfo_close($finfo);
+echo $mime;
+?>
+--EXPECT--
+application/vnd.ms-excel; charset=binary
diff --git a/ext/fileinfo/tests/bug79756.xls b/ext/fileinfo/tests/bug79756.xls
new file mode 100644
index 0000000000..4087523cf7
--- /dev/null
+++ b/ext/fileinfo/tests/bug79756.xls
Binary files differ
diff --git a/main/reentrancy.c b/main/reentrancy.c
index 7a0f7d8f75..776bcb9f35 100644
--- a/main/reentrancy.c
+++ b/main/reentrancy.c
@@ -137,11 +137,14 @@ PHPAPI char *php_ctime_r(const time_t *clock, char *buf)
local_lock(CTIME_R);
tmp = ctime(clock);
- strcpy(buf, tmp);
+ if (tmp) {
+ strcpy(buf, tmp);
+ tmp = buf;
+ }
local_unlock(CTIME_R);
- return buf;
+ return tmp;
}
#endif
@@ -155,11 +158,14 @@ PHPAPI char *php_asctime_r(const struct tm *tm, char *buf)
local_lock(ASCTIME_R);
tmp = asctime(tm);
- strcpy(buf, tmp);
+ if (tmp) {
+ strcpy(buf, tmp);
+ tmp = buf;
+ }
local_unlock(ASCTIME_R);
- return buf;
+ return tmp;
}
#endif