-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #81720: Uninitialized array in pg_query_params() leading to RCE
We must not free parameters which we haven't initialized yet. We also fix the not directly related issue, that we checked for the wrong value being `NULL`, potentially causing a segfault.
- Loading branch information
Showing
2 changed files
with
30 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--TEST-- | ||
Bug #81720 (Uninitialized array in pg_query_params() leading to RCE) | ||
--SKIPIF-- | ||
<?php include("skipif.inc"); ?> | ||
--FILE-- | ||
<?php | ||
include('config.inc'); | ||
|
||
$conn = pg_connect($conn_str); | ||
|
||
try { | ||
pg_query_params($conn, 'SELECT $1, $2', [1, new stdClass()]); | ||
} catch (Throwable $ex) { | ||
echo $ex->getMessage(), PHP_EOL; | ||
} | ||
|
||
try { | ||
pg_send_prepare($conn, "my_query", 'SELECT $1, $2'); | ||
pg_get_result($conn); | ||
pg_send_execute($conn, "my_query", [1, new stdClass()]); | ||
} catch (Throwable $ex) { | ||
echo $ex->getMessage(), PHP_EOL; | ||
} | ||
?> | ||
--EXPECT-- | ||
Object of class stdClass could not be converted to string | ||
Object of class stdClass could not be converted to string |