Re: PHP 4.0 Bug #7509: Problem (buffer overflow?) with ereg()
| From: | Lars Torben Wilson | Date: | Fri, 27 Oct 2000 22:50:28 +0000 |
| Subject: | Re: PHP 4.0 Bug #7509: Problem (buffer overflow?) with ereg() | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-36224@lists.php.net to get a copy of this message | ||
ignacio@openservices.net writes:
> From: ignacio@openservices.net
> Operating system: Red Hat Linux 6.2
> PHP version: 4.0 Latest CVS (28/10/2000)
> PHP Bug Type: Regexps related
> Bug description: Problem (buffer overflow?) with ereg()
>
> When I give ereg() a sufficiently complex RE, PHP seems to roll over
> and die or something the next time it calls ereg(). It has exhibited
> this behavior since 4.0.1pl2, when we first put the code in place.
> Here's the code:
>
> """
> while
> (ereg("^((.|\n)*)<[[:space:]]*[Ff][Oo][Rr][Mm][Ss][Ee][Tt][[:space:]]*([Tt][Yy][Pp][Ee]=(\"[^\"]*\"|[^\">]*))?[[:space:]]*>((.|\n)*)$",
> $string, $out))
I don't know whether this is related to your problem, which, for the
record, I could not reproduce (it worked fine for me), but you could
make the above somewhat simpler by using eregi():
while
(eregi("^((.|\n)*)<[[:space:]]*formset[[:space:]]*(type=(\"[^\"]*\"|[^\">]*))?[[:space:]]*>((.|\n)*)$",
$string, $out))
You could probably also use the faster and IMHO
sometimes-easier-to-read preg_match() for this, if ereg*() isn't
working for you.
Also, do you really *need* to use the system regex? Can you give it a
shot without?
What do you mean by 'die'? Does it segfault or what? Can you generate
a backtrace, or run httpd under gdb or something?
> PHP is configured to use the system RE libs, so I'm wondering if the
> problem might be in there. Nonetheless, I'm putting it in the PHP
> bug list so I can be sure.
I ask 'cause I generally use these functions for much more complex
regexps than that one without difficulty. Although, I must admit that
these days I typically go with preg_*() instead.
--
+----------------------------------------------------------------+
|Torben Wilson <torben@php.net> Netmill iTech|
|http://www.coastnet.com/~torben http://www.netmill.fi|
|Ph: 1 250 383-9735 torben@netmill.fi|
+----------------------------------------------------------------+