summaryrefslogtreecommitdiff
path: root/ext/fileinfo/libmagic
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2019-03-08 20:48:24 +0100
committerAnatol Belski <ab@php.net>2019-03-08 20:48:24 +0100
commitc8ebfaa4ebb2ac55e261a3ccbf7bd464cc71168f (patch)
treea468555a6a6c850e66ffc8b71472677651f35029 /ext/fileinfo/libmagic
parent6ecdd78d7ab804068181db46e0a7b110785435cf (diff)
parent65ffdc2adff1751d085288ca5df14625a69bd7f2 (diff)
downloadphp-git-c8ebfaa4ebb2ac55e261a3ccbf7bd464cc71168f.tar.gz
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fixed bug #77576 pull the libmagic implementation of gmtime_r
Diffstat (limited to 'ext/fileinfo/libmagic')
-rw-r--r--ext/fileinfo/libmagic/cdf_time.c5
-rw-r--r--ext/fileinfo/libmagic/print.c36
2 files changed, 8 insertions, 33 deletions
diff --git a/ext/fileinfo/libmagic/cdf_time.c b/ext/fileinfo/libmagic/cdf_time.c
index 795c843605..bc1b99edaf 100644
--- a/ext/fileinfo/libmagic/cdf_time.c
+++ b/ext/fileinfo/libmagic/cdf_time.c
@@ -23,6 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
+#include "php.h"
#include "file.h"
@@ -152,7 +153,7 @@ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts)
#endif
#ifdef notyet
struct tm tm;
- if (gmtime_r(&ts->ts_sec, &tm) == NULL) {
+ if (php_gmtime_r(&ts->ts_sec, &tm) == NULL) {
errno = EINVAL;
return -1;
}
@@ -168,7 +169,7 @@ cdf_timespec_to_timestamp(cdf_timestamp_t *t, const struct timespec *ts)
char *
cdf_ctime(const time_t *sec, char *buf)
{
- char *ptr = ctime_r(sec, buf);
+ char *ptr = php_ctime_r(sec, buf);
if (ptr != NULL)
return buf;
(void)snprintf(buf, 26, "*Bad* %#16.16" INT64_T_FORMAT "x\n",
diff --git a/ext/fileinfo/libmagic/print.c b/ext/fileinfo/libmagic/print.c
index 9d0121b908..9102c55ec0 100644
--- a/ext/fileinfo/libmagic/print.c
+++ b/ext/fileinfo/libmagic/print.c
@@ -28,7 +28,6 @@
/*
* print.c - debugging printout routines
*/
-#define _GNU_SOURCE
#include "php.h"
#include "file.h"
@@ -45,11 +44,6 @@ FILE_RCSID("@(#)$File: print.c,v 1.82 2017/02/10 18:14:01 christos Exp $")
#endif
#include <time.h>
-#ifdef PHP_WIN32
-# define asctime_r php_asctime_r
-# define ctime_r php_ctime_r
-#endif
-
#define SZOF(a) (sizeof(a) / sizeof(a[0]))
#include "cdf.h"
@@ -240,8 +234,8 @@ protected const char *
file_fmttime(uint64_t v, int flags, char *buf)
{
char *pp;
- time_t t = (time_t)v;
- struct tm *tm = NULL;
+ time_t t;
+ struct tm *tm, tmz;
if (flags & FILE_T_WINDOWS) {
struct timespec ts;
@@ -254,33 +248,13 @@ file_fmttime(uint64_t v, int flags, char *buf)
}
if (flags & FILE_T_LOCAL) {
- pp = ctime_r(&t, buf);
+ tm = php_localtime_r(&t, &tmz);
} else {
-#ifndef HAVE_DAYLIGHT
- private int daylight = 0;
-#ifdef HAVE_TM_ISDST
- private time_t now = (time_t)0;
-
- if (now == (time_t)0) {
- struct tm *tm1;
- (void)time(&now);
- tm1 = localtime(&now);
- if (tm1 == NULL)
- goto out;
- daylight = tm1->tm_isdst;
- }
-#endif /* HAVE_TM_ISDST */
-#endif /* HAVE_DAYLIGHT */
- if (daylight)
- t += 3600;
- tm = gmtime(&t);
- if (tm == NULL)
- goto out;
- pp = asctime_r(tm, buf);
+ tm = php_gmtime_r(&t, &tmz);
}
if (tm == NULL)
goto out;
- pp = asctime_r(tm, buf);
+ pp = php_asctime_r(tm, buf);
if (pp == NULL)
goto out;