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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cestmir at nustep dot net
New email:
PHP Version: OS:

 

 [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: Sun Dec 22 06:01:30 2024 UTC