1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Commit Graph

712 Commits

Author SHA1 Message Date
Niels Dossche
5941cdaaad Fix ZTS crashes with persistent resources in modules (#13381)
On shutdown in ZTS the following happens:
- https://github.com/php/php-src/blob/master/Zend/zend.c#L1124-L1125
  gets executed. This destroys global persistent resources and destroys
  the modules. Furthermore, the modules are unloaded too.
- Further down, `ts_free_id(executor_globals_id)` gets executed, which
  calls `executor_globals_dtor`. This function destroys persistent
  resources for each thread.

Notice that in the last step, the modules that the persistent resource
belong to may already have been destroyed. This means that accessing
globals will cause a crash (I previously fixed this with ifdef magic),
or when the module is dynamically loaded we'll try jumping to a
destructor that is no longer loaded in memory. These scenarios cause
crashes.

It's not possible to move the `ts_free_id` call upwards, because that
may break assumptions of callers, and furthermore this would deallocate
the executor globals structure, which means that any access to those
will cause a segfault.

This patch adds a new API to the TSRM that allows running a callback on
a certain resource type. We use this API to destroy the persistent
resources in all threads prior to the module destruction, and keep the
rest of the resource dtor intact.

I verified this fix on Apache with postgres, both dynamically and
statically.

Fixes GH-12974.
2024-02-13 21:43:03 +01:00
Peter Kokot
3b73db612b Remove unused symbol HAVE_ODBC2 (#13088) 2024-01-08 23:32:46 +01:00
Niels Dossche
20a15ee70b Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-12974: Apache crashes on shutdown when using pg_pconnect()
2023-12-27 20:16:44 +01:00
Niels Dossche
42575ac966 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-12974: Apache crashes on shutdown when using pg_pconnect()
2023-12-27 20:16:32 +01:00
Niels Dossche
77ac1e8592 Fix GH-12974: Apache crashes on shutdown when using pg_pconnect()
On ZTS, the global variables are stored in dynamically allocated memory.
When the module gets shut down this memory is released. After the module
is shut down, only then are the persistent resources cleared. Normally
this isn't an issue, but pgsql and odbc refer to the globals to modify
some counters, after the globals have been freed.
Fix this by guarding the modification.

Closes GH-13032.
2023-12-27 20:14:23 +01:00
David Carlier
70091492d5 Merge branch 'PHP-8.3' 2023-12-23 17:16:04 +00:00
David Carlier
0c8e45e71f Merge branch 'PHP-8.2' into PHP-8.3 2023-12-23 17:15:06 +00:00
David Carlier
d98a45d08c ext/pgsql: pgsql.allow_persistent, no need to use such large type for boolean state.
also ext/odbc, simplifying odd comparison with non persistent connections.

Close GH-12976
2023-12-23 17:14:48 +00:00
Peter Kokot
07a4f89c49 Sync ODBC version (#12922)
When passing `--without-odbcver` or `--with-odbcver=no` to configure,
the ODBC version has been designed to be highest supported version
(0x0350). This syncs the behavior with the Windows build system.
2023-12-11 09:55:30 +01:00
Peter Kokot
5c523edffe Remove obsolete IRIX checks (#12737)
IRIX is a discontinued and closed-source OS with last release in 2006.
2023-11-21 02:56:53 +00:00
Ilija Tovilo
1e5241d49b [skip ci] Re-unparallelize odbc tests
SQL Server frequently deadlocks. Parallelization of these jobs, at least in CI,
is not worthwhile because there are enough tests to run in parallel for the few
workers available.
2023-11-09 11:22:15 +01:00
Saki Takamachi
61c251d7bc Add XLEAK for some msodbcsql tests (#12615) 2023-11-07 18:11:54 +01:00
Saki Takamachi
bbe1222956 Fix GH-12296: [odbc] [pdo_odbc] Optimized odbc connection string creating (#12306)
Declare and initialize on one line

changed to use php_memnistr

store strlen(db) in a variable

Added a semicolon to the end of dsn.

If there is a semicolon at the end of the original dsn, it will be duplicated, so it will be removed.

Add condition when authentication information is null
2023-11-04 13:46:17 +00:00
Ilija Tovilo
5ed58386d1 [skip ci] Skip leaking odbc test on asan 2023-09-08 11:05:34 +02:00
George Peter Banyard
e2667f17bc Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  ODBC unit tests shouldn't override odbc.ini location
  Fix persistent procedural ODBC connections not getting closed
2023-09-06 01:58:11 +01:00
George Peter Banyard
88ed678935 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  ODBC unit tests shouldn't override odbc.ini location
  Fix persistent procedural ODBC connections not getting closed
2023-09-06 01:57:28 +01:00
Calvin Buckley
a648d39297 ODBC unit tests shouldn't override odbc.ini location
`ext/odbc/tests/config.inc` overrides the INIs used for the ODBC driver
manager pointlessly. It's not pointing to some custom PHP test suite
specific one, but the system one in `/etc/odbc(inst).ini`. Which
doesn't necessarily exist, on i.e. NixOS, MacPorts, etc.

Closes GH-12133

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-09-06 01:56:04 +01:00
Calvin Buckley
5a2b251610 Fix persistent procedural ODBC connections not getting closed
Like oci8, procedural ODBC uses an apply function on the hash list to
enumerate persistent connections and close the specific one. However,
this function take zvals, not resources. However, it was getting casted
as such, causing it to interpret the pointer incorrectly. This could
have caused other issues, but mostly manifested as failing to close the
connection even fi it matched.

The function now takes a zval and gets the resource from that. In
addition, it also removes the cast of the function pointer and moves
casting to the function body, to avoid possible confusion like this in
refactors again. It also cleans up style and uses constants in the
function body.

Closes GH-12132

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-09-06 01:55:02 +01:00
George Peter Banyard
508e70ac3c Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix memory leak with failed SQLPrepare
2023-09-02 23:03:04 +01:00
George Peter Banyard
30b550bad5 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix memory leak with failed SQLPrepare
2023-09-02 23:01:08 +01:00
Calvin Buckley
a022ec53bd Fix memory leak with failed SQLPrepare
Closes GH-12095

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-09-02 23:00:06 +01:00
Ilija Tovilo
d1a38e8b8e Fix variable resource ids in odbc test
Ids may vary when using persistent resources. We're not actually interested in
the exact ids anyway.
2023-08-29 12:05:24 +02:00
Máté Kocsis
2f9f2928ce Improve test for odbc_columns()
Hopefully, intermittent test failures will be fixed by creating and using a separate database.

Furthermore, more meaningful test cases are added which also assert the output, as well as wildcard character based searching.
2023-08-29 00:26:25 +02:00
Máté Kocsis
9dcdfa5e3f Use correct format specifier 2023-08-29 00:26:24 +02:00
Máté Kocsis
8726ae0601 Improve and fix ext/odbc tests
Some test failures are fixed, parallelization is enabled, section order is fixed.
2023-08-23 21:20:41 +02:00
Máté Kocsis
66acaba9db Add more test coverage for ext/odbc 2023-08-23 21:20:41 +02:00
Máté Kocsis
038b2ae254 Make the $enable parameter of odbc_autocommit() nullable (#11909)
Co-authored-by: George Peter Banyard <girgias@php.net>
2023-08-08 15:31:58 +02:00
Máté Kocsis
b275e13af7 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix return type of odbc_data_source()
2023-08-08 08:55:36 +02:00
Máté Kocsis
43e62aa21f Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix return type of odbc_data_source()
2023-08-08 08:54:41 +02:00
Máté Kocsis
77252afaf0 Fix return type of odbc_data_source() 2023-08-08 08:52:41 +02:00
George Peter Banyard
163c0b5f4c Merge branch 'PHP-8.2' 2022-09-06 10:42:34 +01:00
George Peter Banyard
5011a185b5 Update globals to use bool type 2022-09-06 10:34:10 +01:00
George Peter Banyard
1ad59b32c2 Update INI validator and displayers depending on INI type
Closes GH-9451
2022-09-06 10:33:34 +01:00
Tim Düsterhus
03fd405423 Use php_info_print_table_header for actual column headers only (#9485)
Using php_info_print_table_header() for "Foo: bar" looks odd and out of place,
because the whole line is colored. It is also questionable from a HTML
semantics point of view, because it does not described the columns that follow.

The use of this across extensions is inconsistent. It was part of the skeleton,
but ext/date or ext/json already use a regular row.
2022-09-06 08:48:22 +02:00
Máté Kocsis
e733ebf30e Add parenthesis around preprocessor conditions in stubs
gen_stub.php concatenates nested #ifs into one #if so let's make sure the semantics remain the same.
2022-09-02 16:21:28 +02:00
Calvin Buckley
f3a14d1b1a Fix GH-9347: Current ODBC liveness checks may be inadequate
We implement SQL_ATTR_CONNECTION_DEAD for ODBC and PDO_ODBC.

This is semantically appropriate and should be used whenever the
driver supports it. In the event that it fails or says the connection
isn't dead (which may be inaccurate in some cases), try the old
heuristic.

Closes GH-9353.
2022-08-29 18:32:31 +02:00
Máté Kocsis
b4ec3e9bc0 Do not generate CONST_CS when registering constants (#9439) 2022-08-28 08:27:19 +02:00
Nikita Popov
ba9debb544 Fix parentheses warnings 2022-07-28 21:09:18 +02:00
Máté Kocsis
236fd4ced2 Declare ext/odbc constants in stubs (#9045) 2022-07-20 11:49:22 +02:00
Remi Collet
55a88f36b6 add SensitiveParameter as known string and use it in arginfo 2022-07-18 11:43:33 +02:00
Tim Düsterhus
342e18f105 Support the actual #[\SensitiveParameter] attribute in stubs (#8836) 2022-07-12 12:43:44 +02:00
Pierrick Charron
6fd2b39397 Indent with TAB in .h files generated by gen_stub 2022-06-13 08:55:54 -04:00
Christoph M. Becker
e7f6acd068 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix handling of single-key connection strings
2022-06-13 14:44:49 +02:00
Christoph M. Becker
4b8bbfb6db Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix handling of single-key connection strings
2022-06-13 14:43:51 +02:00
Calvin Buckley
445d9502bf Fix handling of single-key connection strings
A connection string may contain just a single key, but
PHP used ";" as the heuristic to detect if a string was a connection
string versus plain DSN. However, a single-key connection string
would get treated like a DSN name, i.e. "DSN=*LOCAL". This makes it
so that "=" is used, as a connection string must contain a key.

Closes GH-8748.
2022-06-13 14:41:50 +02:00
Tim Düsterhus
e85b17b934 Mark parameter in ext/odbc as sensitive 2022-06-13 11:09:12 +02:00
Calvin Buckley
2920a26636 Quote when adding to connection string in (PDO_)ODBC
Because the UID= and PWD= values are appended to the SQLDriverConnect
case when credentials are passed, we have to append them to the string
in case users are relying on this behaviour. However, they must be
quoted, or the arguments will be invalid (or possibly more injected).
This means users had to quote arguments or append credentials to the raw
connection string themselves.

It seems that ODBC quoting rules are consistent enough (and that
Microsoft trusts them enough to encode into the .NET BCL) that we can
actually check if the string is already quoted (in case a user is
already quoting because of this not being fixed), and if not, apply the
appropriate ODBC quoting rules.

This is because the code exists in main/, and are shared between
both ODBC extensions, so it doesn't make sense for it to only exist
in one or the other. There may be a better spot for it.

Closes GH-8307.
2022-05-27 16:56:44 +02:00
Christoph M. Becker
c6bb747115 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix ODBC test which may not properly clean up
2022-01-07 19:26:01 +01:00
Christoph M. Becker
0a9f552911 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix ODBC test which may not properly clean up
2022-01-07 19:25:23 +01:00
Christoph M. Becker
9781085782 Fix ODBC test which may not properly clean up
If these tests fail with a fatal error, they won't properly clean up,
which likely causes other tests to fail as (several ODBC tests use the
`odbcTEST` database and tables or stored procedures named `FOO`).  This
is particularly annoying during development, where you would need to
clean up manually.

We fix this by moving the cleanup code to the --CLEAN-- section, so
that this code is executed no matter what.

Closes GH-7886.
2022-01-07 19:23:57 +01:00