From 2c27cb6d0039df8dfa126f7d32845bfd1845d77d Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Mar 2026 08:14:39 -0400 Subject: [PATCH 1/3] ext/fileinfo/libmagic/file.h: delete HAVE_STRCASESTR ifdef PHP's copy of libmagic doesn't use the strcasestr() function, so there is no reason to prototype it, regardless of whether or not the OS (libc) provides it. --- ext/fileinfo/libmagic/file.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/ext/fileinfo/libmagic/file.h b/ext/fileinfo/libmagic/file.h index f8fe588950021..718a60b2e1b00 100644 --- a/ext/fileinfo/libmagic/file.h +++ b/ext/fileinfo/libmagic/file.h @@ -635,9 +635,6 @@ size_t strlcpy(char *, const char *, size_t); #ifndef HAVE_STRLCAT size_t strlcat(char *, const char *, size_t); #endif -#ifndef HAVE_STRCASESTR -char *strcasestr(const char *, const char *); -#endif #ifndef HAVE_GETLINE ssize_t getline(char **, size_t *, FILE *); ssize_t getdelim(char **, size_t *, int, FILE *); From 800800f646ea9c4d71cbac06cf32f616656e8cbc Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Mar 2026 08:16:21 -0400 Subject: [PATCH 2/3] ext/fileinfo/libmagic.patch: update Run ext/fileinfo/generate_patch.sh to re-roll this patch, a recent commit removes HAVE_STRCASESTR from PHP's copy of libmagic. --- ext/fileinfo/libmagic.patch | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ext/fileinfo/libmagic.patch b/ext/fileinfo/libmagic.patch index d2db3c044d3f6..6e3751fa943f8 100644 --- a/ext/fileinfo/libmagic.patch +++ b/ext/fileinfo/libmagic.patch @@ -1727,7 +1727,7 @@ diff -u libmagic.orig/encoding.c libmagic/encoding.c } diff -u libmagic.orig/file.h libmagic/file.h --- libmagic.orig/file.h 2024-11-27 10:37:00.000000000 -0500 -+++ libmagic/file.h 2026-03-24 10:45:21.427536159 -0400 ++++ libmagic/file.h 2026-03-25 08:13:23.336328498 -0400 @@ -27,15 +27,13 @@ */ /* @@ -1883,7 +1883,7 @@ diff -u libmagic.orig/file.h libmagic/file.h typedef struct { char *buf; size_t blen; -@@ -649,19 +629,6 @@ +@@ -649,28 +629,12 @@ extern file_protected const size_t file_nnames; #endif @@ -1903,7 +1903,16 @@ diff -u libmagic.orig/file.h libmagic/file.h #ifndef HAVE_STRLCPY size_t strlcpy(char *, const char *, size_t); #endif -@@ -681,31 +648,6 @@ + #ifndef HAVE_STRLCAT + size_t strlcat(char *, const char *, size_t); + #endif +-#ifndef HAVE_STRCASESTR +-char *strcasestr(const char *, const char *); +-#endif + #ifndef HAVE_GETLINE + ssize_t getline(char **, size_t *, FILE *); + ssize_t getdelim(char **, size_t *, int, FILE *); +@@ -681,31 +645,6 @@ #ifndef HAVE_ASCTIME_R char *asctime_r(const struct tm *, char *); #endif @@ -3066,7 +3075,7 @@ diff -u libmagic.orig/magic.c libmagic/magic.c } return file_getbuffer(ms); diff -u libmagic.orig/magic.h libmagic/magic.h ---- libmagic.orig/magic.h 2026-03-24 10:45:56.975553410 -0400 +--- libmagic.orig/magic.h 2026-03-25 08:16:04.280413419 -0400 +++ libmagic/magic.h 2026-03-20 12:10:19.777614667 -0400 @@ -47,8 +47,6 @@ * extensions */ From cbb90c798820ee4e874fc31ce5826d17f219ac83 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 25 Mar 2026 08:17:53 -0400 Subject: [PATCH 3/3] ext/fileinfo/config.{m4,w32}: don't compile strcasestr.c Unlike the upstream library, PHP's copy of libmagic doesn't use the strcasestr() function, so there is no reason to include strcasestr.c in the list of source files. --- ext/fileinfo/config.m4 | 5 ----- ext/fileinfo/config.w32 | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/ext/fileinfo/config.m4 b/ext/fileinfo/config.m4 index 346061411e086..2d6139f06dff1 100644 --- a/ext/fileinfo/config.m4 +++ b/ext/fileinfo/config.m4 @@ -29,11 +29,6 @@ if test "$PHP_FILEINFO" != "no"; then AC_CHECK_HEADERS([sys/sysmacros.h]) - AC_CHECK_FUNCS([strcasestr],,[ - AC_MSG_NOTICE([using libmagic strcasestr implementation]) - libmagic_sources="$libmagic_sources libmagic/strcasestr.c" - ]) - AX_GCC_FUNC_ATTRIBUTE([visibility]) PHP_NEW_EXTENSION([fileinfo], diff --git a/ext/fileinfo/config.w32 b/ext/fileinfo/config.w32 index 2a42dc45a1d12..34670e7451e48 100644 --- a/ext/fileinfo/config.w32 +++ b/ext/fileinfo/config.w32 @@ -8,7 +8,7 @@ if (PHP_FILEINFO != 'no') { encoding.c fsmagic.c funcs.c \ is_json.c is_tar.c is_simh.c magic.c print.c \ readcdf.c softmagic.c der.c \ - strcasestr.c buffer.c is_csv.c"; + buffer.c is_csv.c"; EXTENSION('fileinfo', 'fileinfo.c php_libmagic.c', true, "/I" + configure_module_dirname + "/libmagic /I" + configure_module_dirname); ADD_EXTENSION_DEP('fileinfo', 'pcre');