com php-src: Fixed bug #66907 Solaris 10 is missing strcasestr and needs substitute: NEWS ext/fileinfo/config.m4 ext/fileinfo/libmagic/strcasestr.c
| From: | Anatol Belski | Date: | Tue, 15 Apr 2014 17:26:49 +0000 |
| Subject: | com php-src: Fixed bug #66907 Solaris 10 is missing strcasestr and needs substitute: NEWS ext/fileinfo/config.m4 ext/fileinfo/libmagic/strcasestr.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-76909@lists.php.net to get a copy of this message | ||
Commit: aaf197180a47d3fe9dfc8a25acdf89c0a7bca059
Author: Anatol Belski <ab@php.net> Tue, 15 Apr 2014 10:26:49 -0700
Parents: bfbb409b32493d7510a943c1201caa89484a0f65
Branches: PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=aaf197180a47d3fe9dfc8a25acdf89c0a7bca059
Log:
Fixed bug #66907 Solaris 10 is missing strcasestr and needs substitute
Bugs:
https://bugs.php.net/66907
Changed paths:
M NEWS
M ext/fileinfo/config.m4
A ext/fileinfo/libmagic/strcasestr.c
Diff:
diff --git a/NEWS b/NEWS
index a5d06dc..f281f5a 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,10 @@ PHP NEWS
. Fixed bug #66721 (__wakeup of DateTime segfaults when invalid object data is
supplied). (Boro Sitnikovski)
+- Fileinfo:
+ .. Fixed bug #66907 (Solaris 10 is missing strcasestr and needs substitute).
+ (Anatol)
+
- FPM:
. Fixed bug #66482 (unknown entry 'priority' in php-fpm.conf).
diff --git a/ext/fileinfo/config.m4 b/ext/fileinfo/config.m4
index 4f34041..a11dbf8 100644
--- a/ext/fileinfo/config..m4
+++ b/ext/fileinfo/config.m4
@@ -13,6 +13,41 @@ if test "$PHP_FILEINFO" != "no"; then
libmagic/is_tar.c libmagic/magic.c libmagic/print.c \
libmagic/readcdf.c libmagic/readelf.c libmagic/softmagic.c"
+ AC_MSG_CHECKING([for strcasestr])
+ AC_TRY_RUN([
+#include <string.h>
+#include <strings.h>
+#include <stdlib.h>
+
+int main(void)
+{
+ char *s0, *s1, *ret;
+
+ s0 = (char *) malloc(42);
+ s1 = (char *) malloc(8);
+
+ memset(s0, 'X', 42);
+ s0[24] = 'Y';
+ s0[26] = 'Z';
+ s0[41] = '\0';
+ memset(s1, 'x', 8);
+ s1[0] = 'y';
+ s1[2] = 'Z';
+ s1[7] = '\0';
+
+ ret = strcasestr(s0, s1);
+
+ return !(NULL != ret);
+}
+ ],[
+ dnl using the platform implementation
+ AC_MSG_RESULT(yes)
+ ],[
+ AC_MSG_RESULT(no)
+ AC_MSG_NOTICE(using libmagic strcasestr implementation)
+ libmagic_sources="$libmagic_sources libmagic/strcasestr.c"
+ ])
+
PHP_NEW_EXTENSION(fileinfo, fileinfo.c $libmagic_sources, $ext_shared,,-I@ext_srcdir@/libmagic)
PHP_ADD_BUILD_DIR($ext_builddir/libmagic)
diff --git a/ext/fileinfo/libmagic/strcasestr.c b/ext/fileinfo/libmagic/strcasestr.c
new file mode 100644
index 0000000..546ed3f
--- /dev/null
+++ b/ext/fileinfo/libmagic/strcasestr.c
@@ -0,0 +1,82 @@
+/* $NetBSD: strcasestr.c,v 1.3 2005/11/29 03:12:00 christos Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+__RCSID("$NetBSD: strcasestr.c,v 1.3 2005/11/29 03:12:00 christos Exp $");
+__RCSID("$NetBSD: strncasecmp..c,v 1.2 2007/06/04 18:19:27 christos Exp $");
+#endif /* LIBC_SCCS and not lint */
+
+#include <assert.h>
+#include <ctype.h>
+#include <string.h>
+
+static int
+_strncasecmp(const char *s1, const char *s2, size_t n)
+{
+ if (n != 0) {
+ const unsigned char *us1 = (const unsigned char *)s1,
+ *us2 = (const unsigned char *)s2;
+
+ do {
+ if (tolower(*us1) != tolower(*us2++))
+ return tolower(*us1) - tolower(*--us2);
+ if (*us1++ == '\0')
+ break;
+ } while (--n != 0);
+ }
+ return 0;
+}
+
+/*
+ * Find the first occurrence of find in s, ignore case.
+ */
+char *
+strcasestr(const char *s, const char *find)
+{
+ char c, sc;
+ size_t len;
+
+ if ((c = *find++) != 0) {
+ c = tolower((unsigned char)c);
+ len = strlen(find);
+ do {
+ do {
+ if ((sc = *s++) == 0)
+ return (NULL);
+ } while ((char)tolower((unsigned char)sc) != c);
+ } while (_strncasecmp(s, find, len) != 0);
+ s--;
+ }
+ return (char *)(intptr_t)(s);
+}