Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation Fault due to PHP bug in preg_match #22

Open
dmitry-kulikov opened this issue Nov 6, 2014 · 0 comments
Open

Segmentation Fault due to PHP bug in preg_match #22

dmitry-kulikov opened this issue Nov 6, 2014 · 0 comments

Comments

@dmitry-kulikov
Copy link

EUriHttp

    public function validateQuery($query = null)
    {
        if ($query === null)
        {
            $query = $this->_query;
        }

        // If query is empty, it is considered to be valid
        if (strlen($query) === 0)
        {
            return true;
        }

        // Determine whether the query is well-formed
        $pattern = '/^' . $this->_regex['uric'] . '*$/';
        $status = @preg_match($pattern, $query);
        if ($status === false)
        {
            throw new CException('Internal error: query validation failed');
        }

        return $status == 1;
    }

preg_match in this function can crash PHP execution if URI is too long.

Possible solution:
ZF-10151: Improved notification in Http.php validateQuery() over preg_match crash caused by PHP backtracking bug

Probably same issue can appear:
EUriHttp

    public function validateFragment($fragment = null)
    {
        if ($fragment === null)
        {
            $fragment = $this->_fragment;
        }

        // If fragment is empty, it is considered to be valid
        if (strlen($fragment) === 0)
        {
            return true;
        }

        // Determine whether the fragment is well-formed
        $pattern = '/^' . $this->_regex['uric'] . '*$/';
        $status = @preg_match($pattern, $fragment);
        if ($status === false)
        {
            throw new CException('Internal error: fragment validation failed');
        }

        return (boolean) $status;
    }
@dmitry-kulikov dmitry-kulikov changed the title Segmentation Fault due PHP bug in preg_match Segmentation Fault due to PHP bug in preg_match Nov 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant