php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23616 preg_match() segfault
Submitted: 2003-05-13 15:33 UTC Modified: 2003-05-15 09:21 UTC
From: cestmir at nustep dot net Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 4.3.2-RC3-dev OS: Linux Debian, Win32
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
6 + 16 = ?
Subscribe to this entry?

 
 [2003-05-13 15:33 UTC] cestmir at nustep dot net
This code causes a segfault both on Linux and Win32 builds.

<?php

function utf8IsValidString($AStr)
{
  $ptrASCII  = '[\x00-\x7F]';
  $ptr2Octet = '[\xC2-\xDF][\x80-\xBF]';
  $ptr3Octet = '[\xE0-\xEF][\x80-\xBF]{2}';
  $ptr4Octet = '[\xF0-\xF4][\x80-\xBF]{3}';
  $ptr5Octet = '[\xF8-\xFB][\x80-\xBF]{4}';
  $ptr6Octet = '[\xFC-\xFD][\x80-\xBF]{5}';

  return preg_match("/^($ptrASCII|$ptr2Octet|$ptr3Octet|$ptr4Octet|$ptr5Octet|$ptr6Octet)*$/s", $AStr);
}

// read text
$handle = fopen('utf8text.txt', 'r');
$stat = fstat($handle);
$str = fread($handle, $stat['size']);
fclose($handle);

// execute PCRE match
var_dump(utf8IsValidString("some short text \xC4\xBE\xC5\xA1")); // ok
var_dump(utf8IsValidString($str));                               // segfault

?>

This code including data file to reproduce bug can be found here: http://www.omikron.sk/downloads/pcre_crash.tar

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-13 15:44 UTC] moriyoshi@php.net
Related to bug #13618
 [2003-05-13 15:48 UTC] moriyoshi@php.net
and related to bug #20698. a PCRE library limitation.
 [2003-05-15 09:21 UTC] sniper@php.net
Not PHP bug.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 06:01:28 2024 UTC