Skip to content

pdo: report correct argument number for constructor option errors - #257

Open
iliaal wants to merge 27 commits into
PHP-8.5from
fix/aph-hw9-85
Open

iliaal wants to merge 27 commits into
PHP-8.5from
fix/aph-hw9-85

Conversation

@iliaal

@iliaal iliaal commented Aug 24, 2026

Copy link
Copy Markdown
Owner

When an attribute passed through the PDO constructor options array failed to set, the resulting error message named argument #3 ($password) instead of argument #4 ($options), because pdo_dbh_attribute_set() was called from php_pdo_internal_construct_driver() with a hardcoded value_arg_num of 3. This passes 4 so errors like an invalid PDO::ATTR_ERRMODE now correctly report Argument #4 ($options). The only other caller, PDO::setAttribute(), already passes the correct number and was audited; a test asserting the corrected message is included and fails without the patch.

@iliaal iliaal closed this Aug 24, 2026
@iliaal iliaal reopened this Aug 24, 2026
iliaal and others added 27 commits September 16, 2026 09:02
SQLite3::close() called from within a userland function, aggregate,
collation or authorizer callback freed the registered statements and
functions while sqlite3 was still executing, corrupting the active
statement and crashing the request. Track callback re-entry with a
per-database counter shared by all four callback kinds and throw an
Error from close() while it is non-zero; the database stays usable and
can be closed after the query completes.

Closes phpGH-23650
* PHP-8.4:
  ext/sqlite3: reject close() from inside a callback
The bridge registered an id as XML_ATTRIBUTE_ID only when lexbor
reported the HTML namespace, so ids on SVG and MathML elements never
reached getElementById(). Separately, lexbor initializes every attribute
node with its element's namespace and overrides that only through the
foreign-attribute adjust table, which the parser wires up for SVG and
MathML alone, so a fragment parsed with an xlink, xml or xmlns context
element came back as <z xlink:id="q" xlink:foo="1">. Restrict the three
namespace branches to attributes lexbor adjusted, and key the id
registration off the namespace the bridge assigned.

Closes phpGH-23598
* PHP-8.4:
  dom: fix attribute namespaces from foreign content in the HTML parser
php_sock_array_to_fd_set() returned a flag rather than the socket count, so
PHP_SAFE_MAX_FD() got a zero and never fired. Sets larger than FD_SETSIZE
were quietly truncated and select() reported on the survivors.

Close phpGH-23632
* PHP-8.4:
  ext/sockets: socket_select() silent set truncation on Windows.
…ansformation.

Fix php#23730

Importing a stylesheet from a php:function callback freed the stylesheet
libxslt was still applying, and the transformation methods kept using the
stale pointer to save the result. The transformation depth is now tracked
on the object and importStylesheet() throws while it is non-zero.

Close phpGH-23737
* PHP-8.4:
  ext/xsl: XSLTProcessor::importStylesheet() use-after-free during a transformation.
… callback.

Fix php#23747

ZipArchive::close() called from a progress or cancel callback ran a
nested zip_close() that failed, then zip_discard() freed the archive
while the outer zip_close() from close() or open() was still using it.
Track the close in progress and throw an Error from close() and open()
meanwhile.

Close phpGH-23749
* PHP-8.4:
  ext/zip: ZipArchive::close() use-after-free from a progress or cancel callback.
…luation

Reconstructing the object from a php:function callback freed the context
libxml2 was still evaluating, and php_xpath_eval() wrote back into it once
the evaluation returned. The evaluation depth is now tracked on the object
and __construct() throws while it is non-zero.

Close phpGH-23735
* PHP-8.4:
  Fix phpGH-23729: DOMXPath::__construct() use-after-free during an evaluation
And thus should never be allowed to be qualified, as this lead to other bugs such as it not considered to be a built-in type by Reflection if it had a namespace component.

We *may* want to extend the unqualified restriction to self and parent in the future.

Closes phpGH-23768
The prompt parser ran as a do-while, so an empty cli.prompt executed
the body on the terminator and scanned past it. Use a while loop and
smart_str_extract(), which returns the interned empty string when
nothing was appended. No regression test: extra unicode warnings from
the over-read depend on heap contents, so a .phpt cannot pin the bug
red-before.

Closes phpGH-23415
* PHP-8.4:
  Fix heap over-read in cli_get_prompt() for empty cli.prompt
init_process_info() memset the pointer parameter instead of the
PROCESS_INFORMATION structure it points at, leaving the struct
uninitialized before CreateProcessW(). Zero it through the pointer.

find_comspec_nt() dereferences *comspec in its cleanup while the
caller only assigns it on success, so a failed SearchPathW() read an
indeterminate value. Initialize the caller's variable to NULL.

set_proc_descriptor_to_blackhole() tested CreateFileA() against NULL,
but CreateFileA() signals failure with INVALID_HANDLE_VALUE, so a
failed open went undetected and an invalid handle was inherited by
the child. Test against INVALID_HANDLE_VALUE.

Closes phpGH-23412
* PHP-8.4:
  Fix three Win32-only defects in proc_open descriptor handling
…tructions with callable conversion

Call level counter was broken: ZEND_CALLABLE_CONVERT was forgotten.

Closes phpGH-23777.
* PHP-8.4:
  Fix OSS-Fuzz #546798343: Heap-buffer-overflow in zend_delete_call_instructions with callable conversion
…ndow

inflate_init() applies the preset dictionary eagerly for raw streams via
inflateSetDictionary(), gated on encoding == PHP_ZLIB_ENCODING_RAW. But
encoding is first adjusted by the window size (encoding += 15 - window),
so a raw stream with a non-default window no longer equals
PHP_ZLIB_ENCODING_RAW and the dictionary is silently dropped; raw streams
carry no header and never emit Z_NEED_DICT, so inflate_add()'s deferred
path never applies it either. Gate on the pre-adjustment encoding. The
deflate side already applies the dictionary unconditionally, so the
roundtrip was broken for this case.

Closes phpGH-22381
The x86 matcher folds v = BINOP(a, b); c = CMP(v, 0); GUARD(c) into
IR_GUARD_JCC_INT, emitting the BINOP, dropping the CMP and branching on
the flags the BINOP left, but it only required the BINOP to precede the
CMP in the IR. Once GCM hoists a loop-invariant BINOP into a dominating
block, the jcc reads flags the intervening code has clobbered and the
guard fires on whatever is in EFLAGS. Require the BINOP to sit in the
guard's block and allow only snapshots between the comparison and the
guard, the way ir_match_fuse_load() pairs ir_in_same_block() with
ir_match_has_mem_deps(). The sibling MEM_BINOP fold already checks the
block, the IF side folds are pinned by full ref adjacency, and
ir_aarch64.dasc has no guard fold.

Mirrors the upstream fix dstogov/ir@51107a3.

Fixes phpGH-23693
Closes phpGH-23711
* PHP-8.4:
  Fix phpGH-23693: JIT guard branches on stale flags across basic blocks
An attribute that fails to set from the PDO constructor options array named
argument #3 ($password) instead of #4 ($options), because
php_pdo_internal_construct_driver() passed a hardcoded value_arg_num of 3
to pdo_dbh_attribute_set(). PDO::setAttribute(), the only other caller,
already passes the correct number.
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

Successfully merging this pull request may close these issues.

6 participants