php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73769 Segfault in preg_match_all
Submitted: 2016-12-17 02:28 UTC Modified: -
Votes:2
Avg. Score:4.0 ± 1.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mozer624 at gmail dot com Assigned:
Status: Open Package: *Regular Expressions
PHP Version: 5.6.29 OS: macOS 10.12
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-12-17 02:28 UTC] mozer624 at gmail dot com
Description:
------------
preg_match_all causes a `Segmentation fault: 11`.

Test script:
---------------
<?php

$pattern = "/^(?P<file>.+?):(?P<line>.+?):(?P<char>.+?): (?P<severity>warning|error): (?P<message>.*) \[(?P<name>.+?)?\]\n(original=\[\[(?P<original>(.|\n)*?)\]\]\nreplacement=\[\[(?P<replacement>(.|\n)*?)\]\])?/m";

$output = <<<EOT
x/x/x.m:520:-8549: error: Using arrayWithObjects:, use @[] instead [Array_With_Objects]
original=[[[NSArray arrayWithObjects:
                                    [NSValue valueWithCGPoint:CGPointMake(1.02, 0.542)],
                                    [NSValue valueWithCGPoint:CGPointMake(1.73, 0.71)],
                                    [NSValue valueWithCGPoint:CGPointMake(2.44, 0.708)],
                                    [NSValue valueWithCGPoint:CGPointMake(3.24, 0.808)],
                                    [NSValue valueWithCGPoint:CGPointMake(3.71, 0.47)],
                                    [NSValue valueWithCGPoint:CGPointMake(4.23, 0.514)],
                                    [NSValue valueWithCGPoint:CGPointMake(4.8, 0.572)],
                                    [NSValue valueWithCGPoint:CGPointMake(5.3, 0.504)],
                                    [NSValue valueWithCGPoint:CGPointMake(6.08, 0.776)],
                                    [NSValue valueWithCGPoint:CGPointMake(6.7, 0.616)],
                                    [NSValue valueWithCGPoint:CGPointMake(7.23, 0.53)],
                                    [NSValue valueWithCGPoint:CGPointMake(7.77, 0.542)],
                                    [NSValue valueWithCGPoint:CGPointMake(8.35, 0.582)],
                                    [NSValue valueWithCGPoint:CGPointMake(9.01, 0.656)],
                                    [NSValue valueWithCGPoint:CGPointMake(9.66, 0.658)],
                                    [NSValue valueWithCGPoint:CGPointMake(10.3, 0.624)],
                                    [NSValue valueWithCGPoint:CGPointMake(11.2, 0.93)],
                                    [NSValue valueWithCGPoint:CGPointMake(11.9, 0.65)],
                                    [NSValue valueWithCGPoint:CGPointMake(12.4, 0.54)],
                                    [NSValue valueWithCGPoint:CGPointMake(13.1, 0.646)],
                                    [NSValue valueWithCGPoint:CGPointMake(13.7, 0.678)],
                                    [NSValue valueWithCGPoint:CGPointMake(14.2, 0.464)],
                                    [NSValue valueWithCGPoint:CGPointMake(14.8, 0.582)],
                                    [NSValue valueWithCGPoint:CGPointMake(15.3, 0.486)],
                                    [NSValue valueWithCGPoint:CGPointMake(15.7, 0.446)],
                                    [NSValue valueWithCGPoint:CGPointMake(16.4, 0.656)],
                                    [NSValue valueWithCGPoint:CGPointMake(16.8, 0.472)],
                                    [NSValue valueWithCGPoint:CGPointMake(17.5, 0.634)],
                                    [NSValue valueWithCGPoint:CGPointMake(18.0, 0.524)],
                                    [NSValue valueWithCGPoint:CGPointMake(18.7, 0.742)],
                                    [NSValue valueWithCGPoint:CGPointMake(19.4, 0.682)],
                                    [NSValue valueWithCGPoint:CGPointMake(19.9, 0.498)],
                                    [NSValue valueWithCGPoint:CGPointMake(20.4, 0.528)],
                                    [NSValue valueWithCGPoint:CGPointMake(21.2, 0.776)],
                                    [NSValue valueWithCGPoint:CGPointMake(21.7, 0.51)],
                                    [NSValue valueWithCGPoint:CGPointMake(22.2, 0.464)],
                                    [NSValue valueWithCGPoint:CGPointMake(22.7, 0.524)],
                                    [NSValue valueWithCGPoint:CGPointMake(23.3, 0.592)],
                                    [NSValue valueWithCGPoint:CGPointMake(23.8, 0.536)],
                                    [NSValue valueWithCGPoint:CGPointMake(24.4, 0.558)],
                                    [NSValue valueWithCGPoint:CGPointMake(25.2, 0.838)],
                                    [NSValue valueWithCGPoint:CGPointMake(25.8, 0.556)],
                                    [NSValue valueWithCGPoint:CGPointMake(26.4, 0.55)],
                                    [NSValue valueWithCGPoint:CGPointMake(27.0, 0.672)],
                                    [NSValue valueWithCGPoint:CGPointMake(27.8, 0.766)],
                                    [NSValue valueWithCGPoint:CGPointMake(28.4, 0.652)],
                                    [NSValue valueWithCGPoint:CGPointMake(29.1, 0.61)],
                                    [NSValue valueWithCGPoint:CGPointMake(30.2, 1.19)],
                                    [NSValue valueWithCGPoint:CGPointMake(30.8, 0.598)],
                                    [NSValue valueWithCGPoint:CGPointMake(31.5, 0.696)],
                                    [NSValue valueWithCGPoint:CGPointMake(32.0, 0.428)],
                                    [NSValue valueWithCGPoint:CGPointMake(32.6, 0.632)],
                                    [NSValue valueWithCGPoint:CGPointMake(33.4, 0.766)],
                                    [NSValue valueWithCGPoint:CGPointMake(34.2, 0.838)],
                                    [NSValue valueWithCGPoint:CGPointMake(34.9, 0.728)],
                                    [NSValue valueWithCGPoint:CGPointMake(35.5, 0.608)],
                                    [NSValue valueWithCGPoint:CGPointMake(36.0, 0.44)],
                                    [NSValue valueWithCGPoint:CGPointMake(36.8, 0.854)],
                                    [NSValue valueWithCGPoint:CGPointMake(37.3, 0.476)],
                                    [NSValue valueWithCGPoint:CGPointMake(38.0, 0.686)],
                                    [NSValue valueWithCGPoint:CGPointMake(38.5, 0.482)],
                                    [NSValue valueWithCGPoint:CGPointMake(39.0, 0.574)],
                                    [NSValue valueWithCGPoint:CGPointMake(39.7, 0.664)],
                                    [NSValue valueWithCGPoint:CGPointMake(40.2, 0.504)],
                                    [NSValue valueWithCGPoint:CGPointMake(41.1, 0.878)],
                                    [NSValue valueWithCGPoint:CGPointMake(41.6, 0.552)],
                                    [NSValue valueWithCGPoint:CGPointMake(42.5, 0.804)],
                                    [NSValue valueWithCGPoint:CGPointMake(43.0, 0.536)],
                                    [NSValue valueWithCGPoint:CGPointMake(43.5, 0.486)],
                                    [NSValue valueWithCGPoint:CGPointMake(44.1, 0.586)],
                                    [NSValue valueWithCGPoint:CGPointMake(44.6, 0.494)],
                                    [NSValue valueWithCGPoint:CGPointMake(45.4, 0.892)],
                                    [NSValue valueWithCGPoint:CGPointMake(46.0, 0.532)],
                                    [NSValue valueWithCGPoint:CGPointMake(46.5, 0.572)],
                                    [NSValue valueWithCGPoint:CGPointMake(47.1, 0.592)],
                                    [NSValue valueWithCGPoint:CGPointMake(47.8, 0.684)],
                                    [NSValue valueWithCGPoint:CGPointMake(48.4, 0.58)],
                                    [NSValue valueWithCGPoint:CGPointMake(48.9, 0.474)],
                                    [NSValue valueWithCGPoint:CGPointMake(49.5, 0.648)],
                                    [NSValue valueWithCGPoint:CGPointMake(50.1, 0.554)],
                                    [NSValue valueWithCGPoint:CGPointMake(50.6, 0.476)],
                                    [NSValue valueWithCGPoint:CGPointMake(51.2, 0.602)],
                                    [NSValue valueWithCGPoint:CGPointMake(51.8, 0.686)],
                                    [NSValue valueWithCGPoint:CGPointMake(52.4, 0.6)],
                                    [NSValue valueWithCGPoint:CGPointMake(53.1, 0.632)],
                                    [NSValue valueWithCGPoint:CGPointMake(53.6, 0.556)],
                                    [NSValue valueWithCGPoint:CGPointMake(54.1, 0.514)],
                                    [NSValue valueWithCGPoint:CGPointMake(54.8, 0.62)],
                                    [NSValue valueWithCGPoint:CGPointMake(55.3, 0.58)],
                                    [NSValue valueWithCGPoint:CGPointMake(56.0, 0.642)],
                                    [NSValue valueWithCGPoint:CGPointMake(56.7, 0.742)],
                                    [NSValue valueWithCGPoint:CGPointMake(57.5, 0.76)],
                                    [NSValue valueWithCGPoint:CGPointMake(58.1, 0.57)],
                                    [NSValue valueWithCGPoint:CGPointMake(58.5, 0.478)],
                                    [NSValue valueWithCGPoint:CGPointMake(59.2, 0.652)],
                                    [NSValue valueWithCGPoint:CGPointMake(59.7, 0.558)],
                                    nil]]]
replacement=[[@[
                                    [NSValue valueWithCGPoint:CGPointMake(1.02, 0.542)],
                                    [NSValue valueWithCGPoint:CGPointMake(1.73, 0.71)],
                                    [NSValue valueWithCGPoint:CGPointMake(2.44, 0.708)],
                                    [NSValue valueWithCGPoint:CGPointMake(3.24, 0.808)],
                                    [NSValue valueWithCGPoint:CGPointMake(3.71, 0.47)],
                                    [NSValue valueWithCGPoint:CGPointMake(4.23, 0.514)],
                                    [NSValue valueWithCGPoint:CGPointMake(4.8, 0.572)],
                                    [NSValue valueWithCGPoint:CGPointMake(5.3, 0.504)],
                                    [NSValue valueWithCGPoint:CGPointMake(6.08, 0.776)],
                                    [NSValue valueWithCGPoint:CGPointMake(6.7, 0.616)],
                                    [NSValue valueWithCGPoint:CGPointMake(7.23, 0.53)],
                                    [NSValue valueWithCGPoint:CGPointMake(7.77, 0.542)],
                                    [NSValue valueWithCGPoint:CGPointMake(8.35, 0.582)],
                                    [NSValue valueWithCGPoint:CGPointMake(9.01, 0.656)],
                                    [NSValue valueWithCGPoint:CGPointMake(9.66, 0.658)],
                                    [NSValue valueWithCGPoint:CGPointMake(10.3, 0.624)],
                                    [NSValue valueWithCGPoint:CGPointMake(11.2, 0.93)],
                                    [NSValue valueWithCGPoint:CGPointMake(11.9, 0.65)],
                                    [NSValue valueWithCGPoint:CGPointMake(12.4, 0.54)],
                                    [NSValue valueWithCGPoint:CGPointMake(13.1, 0.646)],
                                    [NSValue valueWithCGPoint:CGPointMake(13.7, 0.678)],
                                    [NSValue valueWithCGPoint:CGPointMake(14.2, 0.464)],
                                    [NSValue valueWithCGPoint:CGPointMake(14.8, 0.582)],
                                    [NSValue valueWithCGPoint:CGPointMake(15.3, 0.486)],
                                    [NSValue valueWithCGPoint:CGPointMake(15.7, 0.446)],
                                    [NSValue valueWithCGPoint:CGPointMake(16.4, 0.656)],
                                    [NSValue valueWithCGPoint:CGPointMake(16.8, 0.472)],
                                    [NSValue valueWithCGPoint:CGPointMake(17.5, 0.634)],
                                    [NSValue valueWithCGPoint:CGPointMake(18.0, 0.524)],
                                    [NSValue valueWithCGPoint:CGPointMake(18.7, 0.742)],
                                    [NSValue valueWithCGPoint:CGPointMake(19.4, 0.682)],
                                    [NSValue valueWithCGPoint:CGPointMake(19.9, 0.498)],
                                    [NSValue valueWithCGPoint:CGPointMake(20.4, 0.528)],
                                    [NSValue valueWithCGPoint:CGPointMake(21.2, 0.776)],
                                    [NSValue valueWithCGPoint:CGPointMake(21.7, 0.51)],
                                    [NSValue valueWithCGPoint:CGPointMake(22.2, 0.464)],
                                    [NSValue valueWithCGPoint:CGPointMake(22.7, 0.524)],
                                    [NSValue valueWithCGPoint:CGPointMake(23.3, 0.592)],
                                    [NSValue valueWithCGPoint:CGPointMake(23.8, 0.536)],
                                    [NSValue valueWithCGPoint:CGPointMake(24.4, 0.558)],
                                    [NSValue valueWithCGPoint:CGPointMake(25.2, 0.838)],
                                    [NSValue valueWithCGPoint:CGPointMake(25.8, 0.556)],
                                    [NSValue valueWithCGPoint:CGPointMake(26.4, 0.55)],
                                    [NSValue valueWithCGPoint:CGPointMake(27.0, 0.672)],
                                    [NSValue valueWithCGPoint:CGPointMake(27.8, 0.766)],
                                    [NSValue valueWithCGPoint:CGPointMake(28.4, 0.652)],
                                    [NSValue valueWithCGPoint:CGPointMake(29.1, 0.61)],
                                    [NSValue valueWithCGPoint:CGPointMake(30.2, 1.19)],
                                    [NSValue valueWithCGPoint:CGPointMake(30.8, 0.598)],
                                    [NSValue valueWithCGPoint:CGPointMake(31.5, 0.696)],
                                    [NSValue valueWithCGPoint:CGPointMake(32.0, 0.428)],
                                    [NSValue valueWithCGPoint:CGPointMake(32.6, 0.632)],
                                    [NSValue valueWithCGPoint:CGPointMake(33.4, 0.766)],
                                    [NSValue valueWithCGPoint:CGPointMake(34.2, 0.838)],
                                    [NSValue valueWithCGPoint:CGPointMake(34.9, 0.728)],
                                    [NSValue valueWithCGPoint:CGPointMake(35.5, 0.608)],
                                    [NSValue valueWithCGPoint:CGPointMake(36.0, 0.44)],
                                    [NSValue valueWithCGPoint:CGPointMake(36.8, 0.854)],
                                    [NSValue valueWithCGPoint:CGPointMake(37.3, 0.476)],
                                    [NSValue valueWithCGPoint:CGPointMake(38.0, 0.686)],
                                    [NSValue valueWithCGPoint:CGPointMake(38.5, 0.482)],
                                    [NSValue valueWithCGPoint:CGPointMake(39.0, 0.574)],
                                    [NSValue valueWithCGPoint:CGPointMake(39.7, 0.664)],
                                    [NSValue valueWithCGPoint:CGPointMake(40.2, 0.504)],
                                    [NSValue valueWithCGPoint:CGPointMake(41.1, 0.878)],
                                    [NSValue valueWithCGPoint:CGPointMake(41.6, 0.552)],
                                    [NSValue valueWithCGPoint:CGPointMake(42.5, 0.804)],
                                    [NSValue valueWithCGPoint:CGPointMake(43.0, 0.536)],
                                    [NSValue valueWithCGPoint:CGPointMake(43.5, 0.486)],
                                    [NSValue valueWithCGPoint:CGPointMake(44.1, 0.586)],
                                    [NSValue valueWithCGPoint:CGPointMake(44.6, 0.494)],
                                    [NSValue valueWithCGPoint:CGPointMake(45.4, 0.892)],
                                    [NSValue valueWithCGPoint:CGPointMake(46.0, 0.532)],
                                    [NSValue valueWithCGPoint:CGPointMake(46.5, 0.572)],
                                    [NSValue valueWithCGPoint:CGPointMake(47.1, 0.592)],
                                    [NSValue valueWithCGPoint:CGPointMake(47.8, 0.684)],
                                    [NSValue valueWithCGPoint:CGPointMake(48.4, 0.58)],
                                    [NSValue valueWithCGPoint:CGPointMake(48.9, 0.474)],
                                    [NSValue valueWithCGPoint:CGPointMake(49.5, 0.648)],
                                    [NSValue valueWithCGPoint:CGPointMake(50.1, 0.554)],
                                    [NSValue valueWithCGPoint:CGPointMake(50.6, 0.476)],
                                    [NSValue valueWithCGPoint:CGPointMake(51.2, 0.602)],
                                    [NSValue valueWithCGPoint:CGPointMake(51.8, 0.686)],
                                    [NSValue valueWithCGPoint:CGPointMake(52.4, 0.6)],
                                    [NSValue valueWithCGPoint:CGPointMake(53.1, 0.632)],
                                    [NSValue valueWithCGPoint:CGPointMake(53.6, 0.556)],
                                    [NSValue valueWithCGPoint:CGPointMake(54.1, 0.514)],
                                    [NSValue valueWithCGPoint:CGPointMake(54.8, 0.62)],
                                    [NSValue valueWithCGPoint:CGPointMake(55.3, 0.58)],
                                    [NSValue valueWithCGPoint:CGPointMake(56.0, 0.642)],
                                    [NSValue valueWithCGPoint:CGPointMake(56.7, 0.742)],
                                    [NSValue valueWithCGPoint:CGPointMake(57.5, 0.76)],
                                    [NSValue valueWithCGPoint:CGPointMake(58.1, 0.57)],
                                    [NSValue valueWithCGPoint:CGPointMake(58.5, 0.478)],
                                    [NSValue valueWithCGPoint:CGPointMake(59.2, 0.652)],
                                    [NSValue valueWithCGPoint:CGPointMake(59.7, 0.558)]]]]
EOT;


$matches = null;
var_dump(preg_match_all($pattern, $output, $matches, PREG_SET_ORDER));
var_dump($matches);


?>

Expected result:
----------------
No seg fault and actually a match with the regex.


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Oct 22 18:01:31 2019 UTC