Skip to content

Commit

Permalink
Fix result_type related stack corruption on LLP64 architectures
Browse files Browse the repository at this point in the history
Integer parameters are stored in `zend_long` values, which have 64 bits
on LLP64, but `long` has only 32 bits there.

Adding a test might be overkill, because the broken behavior could
already be observed when running pg_select_001.phpt on Windows debug
builds, which report the stack corruption.

Closes GH-8263.
  • Loading branch information
cmb69 committed Mar 28, 2022
1 parent 771dbdb commit 5a8622f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ PHP NEWS
- Pcntl:
. Fixed bug GH-8142 (Compilation error on cygwin). (David Carlier)

- PgSQL:
. Fixed result_type related stack corruption on LLP64 architectures. (cmb)

- Sockets:
. Fixed Solaris builds. (David Carlier)

Expand Down
4 changes: 2 additions & 2 deletions ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,7 @@ PHP_FUNCTION(pg_fetch_object)
PHP_FUNCTION(pg_fetch_all)
{
zval *result;
long result_type = PGSQL_ASSOC;
zend_long result_type = PGSQL_ASSOC;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;

Expand Down Expand Up @@ -5896,7 +5896,7 @@ PHP_FUNCTION(pg_select)
char *table;
size_t table_len;
zend_ulong option = PGSQL_DML_EXEC;
long result_type = PGSQL_ASSOC;
zend_long result_type = PGSQL_ASSOC;
PGconn *pg_link;
zend_string *sql = NULL;

Expand Down

0 comments on commit 5a8622f

Please sign in to comment.