douwei7501 2012-06-24 19:24
浏览 45
已采纳

使用php在FILTER_VALIDATE_EMAIL上“重置连接”

I do not find anything on the web and I don't know why: Calling

filter_var($address, FILTER_VALIDATE_EMAIL)

leads to the connection being reset (at least that's what Firefox tells me). The server has PHP version 5.3.13 with Suhosin-Patch on FreeBSD. Testing this on my own server which runs Debian and PHP version 5.3.3 also with Suhosin works fine, though I seem to remember it did show the same behaviour before.

PHP manual indicates this was introduced on PHP 5.2.0 so it should work, shouldn't it?

Edit: To better show what fails, I show you two examples, one with reset, the other with a proper die("message");

This example outputs Before validate on the browser Window:

if (function_exists('filter_var')) { //Introduced in PHP 5.2

    die("Before validate");
  if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {
    return false;
  } else {
    return true;
  }
} else {
return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
}

The example leads to the aforementioned "connection was reset...":

if (function_exists('filter_var')) { //Introduced in PHP 5.2


  if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) {

  die("After validate");
    return false;
  } else {

  die("After validate");
    return true;
  }
} else {
  return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address);
}

I do not get an output like "After validate" here. Also the address is a very easy "no-reply@domain.com" address, so its even valid.

Okay another edit: I made a oneliner running only this function and executed it on the console. This is the output:

/libexec/ld-elf.so.1: /usr/local/lib/php/20090626/filter.so: Undefined symbol "php_pcre_exec"

I handed this over to the server admin. From what I found on google, a simple update could solve it, but I will have to wait for his answer. If the issue is solved, I will note this here. Until then this will have to rest, as I cannot fix such a system-deep error.

  • 写回答

1条回答 默认 最新

  • doukun8670 2012-06-24 19:46
    关注

    in this suhosin summary they talk about a fix to a segfault when using that flag, it's an opensuse report but it might be that your install is susceptible to it. You'll probably need to make sure that your suhosin patch is up to at least what corresponds to opensuse's version 0.17.1. Problem is I can't find anything about it on suhosin's official changelog. Where does freebsd get their port source from in this case?

    • Tue Oct 26 2010 pgajdos@novell.com
      • fix "Segfault in filter_var with FILTER_VALIDATE_EMAIL with large amount of data" [bnc#649210]
      • CVE-2010-3710.patch
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算