return 0;
}
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+
+static inline size_t sapi_cgibin_single_write(const char *str, uint str_length)
+{
+#ifdef PHP_WRITE_STDOUT
+ long ret;
+
+ ret = write(STDOUT_FILENO, str, str_length);
+ if (ret <= 0) return 0;
+ return ret;
+#else
+ size_t ret;
+
+ ret = fwrite(str, 1, MIN(str_length, 16384), stdout);
+ return ret;
+#endif
+}
+
static int sapi_cgibin_ub_write(const char *str, uint str_length)
{
const char *ptr = str;
while (remaining > 0)
{
- ret = fwrite(ptr, 1, MIN(remaining, 16384), stdout);
+ ret = sapi_cgibin_single_write(ptr, remaining);
if (!ret) {
php_handle_aborted_connection();
}
+AC_DEFUN(PHP_TEST_WRITE_STDOUT,[
+ AC_CACHE_CHECK(whether writing to stdout works,ac_cv_write_stdout,[
+ AC_TRY_RUN([
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#define TEXT "This is the test message -- "
+
+main()
+{
+ int n;
+
+ n = write(1, TEXT, sizeof(TEXT)-1);
+ return (!(n == sizeof(TEXT)-1));
+}
+ ],[
+ ac_cv_write_stdout=yes
+ ],[
+ ac_cv_write_stdout=no
+ ],[
+ ac_cv_write_stdout=no
+ ])
+ ])
+ if test "$ac_cv_write_stdout" = "yes"; then
+ AC_DEFINE(PHP_WRITE_STDOUT, 1, [whether write(2) works])
+ fi
+])
if test "$PHP_SAPI" = "cgi"; then
+ PHP_TEST_WRITE_STDOUT
+
PHP_ARG_ENABLE(force-cgi-redirect,whether to force Apache CGI redirect,
[ --enable-force-cgi-redirect
Enable the security check for internal server