Merge branch 'PHP-7.3' into PHP-7.4

* PHP-7.3:
  Fix #79756: finfo_file crash (FILEINFO_MIME)
This commit is contained in:
Christoph M. Becker 2020-06-29 17:46:31 +02:00
commit dfac28f8d8
4 changed files with 29 additions and 4 deletions

3
NEWS
View File

@ -10,6 +10,9 @@ PHP NEWS
. Fixed bug #79740 (serialize() and unserialize() methods can not be called
statically). (Nikita)
- Fileinfo:
. Fixed bug #79756 (finfo_file crash (FILEINFO_MIME)). (cmb)
- FTP:
. Fixed bug #55857 (ftp_size on large files). (cmb)

View File

@ -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

Binary file not shown.

View File

@ -139,11 +139,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
@ -157,11 +160,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