Skip to content

Commit 5c9cb24

Browse files
committed
libmagic: Follow up fixes for 5.43
Fixes possible build and runtime issues on Windows.` Signed-off-by: Anatol Belski <ab@php.net>
1 parent 25bb817 commit 5c9cb24

File tree

5 files changed

+7
-10
lines changed

5 files changed

+7
-10
lines changed

ext/fileinfo/libmagic/apprentice.c

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ FILE_RCSID("@(#)$File: apprentice.c,v 1.326 2022/09/13 18:46:07 christos Exp $")
4848
#ifdef QUICK
4949
#include <sys/mman.h>
5050
#endif
51-
#include <dirent.h>
5251
#include <limits.h>
5352
#ifdef HAVE_BYTESWAP_H
5453
#include <byteswap.h>

ext/fileinfo/libmagic/ascmagic.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,8 @@ file_ascmagic_with_encoding(struct magic_set *ms, const struct buffer *b,
273273
goto done;
274274

275275
if (has_long_lines)
276-
if (file_printf(ms, ", with very long lines (%"
277-
SIZE_T_FORMAT "u)", has_long_lines) == -1)
276+
if (file_printf(ms, ", with very long lines (%zu)",
277+
has_long_lines) == -1)
278278
goto done;
279279

280280
/*

ext/fileinfo/libmagic/magic.c

-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@
2525
* SUCH DAMAGE.
2626
*/
2727

28-
#ifdef WIN32
29-
#include <windows.h>
30-
#include <shlwapi.h>
31-
#endif
32-
3328
#include "file.h"
3429

3530
#ifndef lint

ext/fileinfo/libmagic/softmagic.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ mprint(struct magic_set *ms, struct magic *m)
772772
char *cp, *scp;
773773
int rval;
774774

775-
cp = strndup(RCAST(const char *, ms->search.s),
775+
cp = estrndup(RCAST(const char *, ms->search.s),
776776
ms->search.rm_len);
777777
if (cp == NULL) {
778778
file_oomem(ms, ms->search.rm_len);
@@ -782,7 +782,7 @@ mprint(struct magic_set *ms, struct magic *m)
782782

783783
rval = file_printf(ms, F(ms, desc, "%s"), file_printable(ms,
784784
sbuf, sizeof(sbuf), scp, ms->search.rm_len));
785-
free(cp);
785+
efree(cp);
786786

787787
if (rval == -1)
788788
return -1;

ext/fileinfo/php_libmagic.h

+3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636

3737
#define strtoull _strtoui64
3838

39+
40+
#define HAVE_ASCTIME_R 1
3941
#define asctime_r php_asctime_r
42+
#define HAVE_CTIME_R 1
4043
#define ctime_r php_ctime_r
4144

4245
#else

0 commit comments

Comments
 (0)