hi,

> > indeed it is theoretically impossible to track this :)
> >
> > implement a recursive alrorithm for something e.g.:
> >
> > function foo($n) { // calc $n!
> >     if ($n<=1)
> >         return $n;
> >     else
> >         return foo($n-1)*$n;
> > }
> >
> > now tell me if it is infinite or finite? ;-) this is a verification and
> > cannot be solved runtime.
> >
> > the best thing that can be done is to set a stack limit (php function
call
> > level) to something reasonable and thus avoid the segfault.
>
> This gives a problem itself, how many levels before the stack is full? Not
> every function call has the same memory footprint, so you can't tell after
> how many levels the stack is full.

of course. but it is better to set something like 1000(or 1000000) and be
sure that a malicious user cannot exploit it. as far as i remember php local
vars are emalloc-ed and are not on the stack. so there is an average value
like 64(or 640) bytes per stack frame or something...

b.


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to