diff --git a/ext/fileinfo/tests/bug79756.phpt b/ext/fileinfo/tests/bug79756.phpt new file mode 100644 index 0000000000000..4aeeb2a266faa --- /dev/null +++ b/ext/fileinfo/tests/bug79756.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #79756 (finfo_file crash (FILEINFO_MIME)) +--SKIPIF-- + +--FILE-- + +--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 0000000000000..4087523cf7cfe Binary files /dev/null and b/ext/fileinfo/tests/bug79756.xls differ diff --git a/main/reentrancy.c b/main/reentrancy.c index 213e82bd8c456..6699817510b56 100644 --- a/main/reentrancy.c +++ b/main/reentrancy.c @@ -187,11 +187,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 @@ -205,11 +208,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