[pull] master from laruence:master - #16
Merged
Merged
Conversation
yaf_call_user_method() returns 0 without touching ret when the action method is protected/private, so the uninitialized `zval ret` in yaf_dispatcher_handle() was read by Z_ISUNDEF()/zval_ptr_dtor(), and args was efree'd twice when count > 0. Initialize ret to UNDEF (as the bootstrap path in yaf_application.c already does) and release args exactly once.
yaf_dispatcher_instance() dereferenced YAF_G(app) unconditionally, so calling Yaf_Dispatcher::getInstance() before any Yaf_Application was created crashed with SIGSEGV. Guard on Z_TYPE(YAF_G(app)) and throw a startup error (same convention as the "Only one application" error) instead.
A zero limit underflows the dispatch-loop counter (--nesting from 0) and spins forever; storing 0 in the loader flags slot leaves the same trap armed. Fall back to YAF_DEFAULT_FORWARD_LIMIT instead so the counter is always positive.
ZEND_HASH_FOREACH_STR_KEY_VAL yields a NULL key for integer-indexed entries; snprintf then dereferenced it while composing the "yaf.*" ini name. Skip numeric keys since no ini entry can be named after them anyway.
When forward() is called in a controller's init(), the dispatcher used to tail-recurse into itself for every hop, bypassing the forward_limit counter and blowing the stack with an uncaught fatal error on a forwarding loop. Return to the dispatch loop instead, where each hop is counted and capped like any other forward.
yaf_route_instance() fell through to "return 1" when the configured type matched none of the built-in routes, handing the caller a zval that was never written (stack garbage). The default-route path then OBJ_RELEASE'd that garbage on failure. Return 0 for unknown types, and initialize the caller's zval to UNDEF so the failure path is safe.
The supervar is looked up in \$_GET, which may hold an array (e.g. ?r[a]=b). Reading Z_STRVAL/Z_STRLEN of a non-string zval crashed the router; require IS_STRING and fail the route otherwise.
A cached pointer into $_SESSION dangles once userland unsets the variable or the session is destroyed, while holding a reference silently detaches the session object from the live array and breaks copy-on-write. Instead resolve the array straight from the symbol table on every access and fail gracefully when it is gone.
yaf_loader_load_mvc() handed the bare class-name length down, but yaf_loader_import() uses the length to seed the zend_string it registers in EG(included_files), truncating the key. Recompute the final path length and assert the caller always passes the full length.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )