Commit Graph

345 Commits

Author SHA1 Message Date
Christoph M. Becker
1b7ee6db88 Fix com_safearray_proxy related memory management issues 2020-08-26 15:39:32 +02:00
Christoph M. Becker
75ac3f1cba Separate COM::__construct()s $server_name array
This may otherwise be modified.
2020-08-26 15:00:02 +02:00
Christoph M. Becker
5ff15e2651 Fix #64130: COM obj parameters passed by reference are not updated
`ITypeInfo_GetIDsOfNames()` is supposed to fail with `E_NOTIMPL` for
out-of-process servers, thus we should not remove the already available
typeinfo of the object in this case.

We also properly free the `byref_vals`.
2020-08-26 14:50:04 +02:00
Christoph M. Becker
3324bb893e Avoid double-free
As of commit b2e3fd1[1] the `authid.User` is no longer newly allocated,
so we must not free it.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=b2e3fd1e691b1dc82aaaf4150461db97bd5acf4a>
2020-08-25 13:11:22 +02:00
Christoph M. Becker
dc108feab8 Fix #48585: com_load_typelib holds reference, fails on second call
Whether the type library is cached is actually irrelevant here; what
matters is that the symbols are imported, and since these are not
cached, we have to import them for every request.  And we cannot cache
the symbols, because the import depends on the current codepage, but
the codepage is a `PHP_INI_ALL` setting.
2020-08-11 11:26:50 +02:00
Christoph M. Becker
b2e3fd1e69 Fix #63527: DCOM does not work with Username, Password parameter
We must not mix multibyte and wide character strings in the
`COAUTHIDENTITY` structure.  Using wide character strings throughout
would have the advantage that the remote connection can be established
regardless of the code page of the server, but that would more likely
break BC, so we just drop the wide character string conversion of the
username.
2020-07-20 14:43:29 +02:00
Christoph M. Becker
a385cfa7ad Fix #63208: BSTR to PHP string conversion not binary safe
A `BSTR` is similar to a `zend_string`; it stores the length of the
string just before the actual string, and thus the string may contain
NUL bytes.  However, `php_com_olestring_to_string()` is supposed to
deal with arbitrary `OLECHAR*`s which may not be `BSTR`s, so we
introduce `php_com_bstr_to_string()` and use it for the only case where
we actually have to deal with `BSTR`s which may contain NUL bytes.

Contrary to `php_com_olestring_to_string()` we return a `zend_string`,
so we can save the re-allocation when converting to a `zval`.

We also cater to `php_com_string_to_olestring()` not being binary safe,
with basically the same fix we did for `php_com_olestring_to_string()`.
2020-06-29 19:05:02 +02:00
Lukas Berger
7f9b534e3a Add missing 'skip' to bug79332.phpt skip message
The skip message must start with the word 'skip', otherwise the test will not be skipped.

*Before:*
Running selected tests.
TEST 1/1 [ext/com_dotnet/tests/bug79332.phpt]
========DIFF========
001+ Fatal error: Uncaught Error: Class 'COMPersistHelper' not found in /srv/php/ext/com_dotnet/tests/bug79332.php:2
001- A com_exception has been thrown
002+ Stack trace:
003+ #0 {main}
004+   thrown in /srv/php/ext/com_dotnet/tests/bug79332.php on line 2
========DONE========
FAIL Bug #79332 (php_istreams are never freed) [ext/com_dotnet/tests/bug79332.phpt]

*After:*
Running selected tests.
SKIP Bug #79332 (php_istreams are never freed) [ext/com_dotnet/tests/bug79332.phpt] reason: com_dotnet extension not available
2020-03-26 23:14:10 +01:00
Christoph M. Becker
53140e5c56 Fix #79333: com_print_typeinfo() leaks memory
We have to free the `ansiname`s, regardless of whether they have been
put into the hashtable or not.

Since bug79299.phpt already shows the leak when run with a leak
checker, there is no need for another regression test.
2020-03-02 11:36:30 +01:00
Christoph M. Becker
2adf1c4d23 Fix #79332: php_istreams are never freed
Releasing the `com_dotnet_istream_wrapper` in `istream_destructor()` is
pointless, since `istream_destructor()` is only called when the
resource is going to be released.  This recursion is not a real issue,
though, since the resource is never exposed to userland, and has at
most refcount 1, so due to well defined unsigned integer underflow, it
never is released twice.  However, returning early in this case causes
a memory leak which needs to be fixed.
2020-03-02 10:45:37 +01:00
Christoph M. Becker
9e6358af36 Fix #79299: com_print_typeinfo prints duplicate variables
`lastid` has to retain its value during the traversal, so we move it to
an outer scope.

Patch contributed by Litiano Moura.
2020-02-23 23:31:36 +01:00
Christoph M. Becker
f649adedfe Fix #79248: Traversing empty VT_ARRAY throws com_exception
If the `VT_ARRAY` is empty, i.e. its upperbound is less than its lower
bound, we must not call `php_com_safearray_get_elem()`, because that
function throws in this case.
2020-02-08 17:05:29 +01:00
Christoph M. Becker
674d44ad7c Skip test case on x86 where it otherwise fails [ci skip]
`-2200000000` can't be converted to integer on x86, so the constructor
call would fail.
2020-02-07 21:09:35 +01:00
Christoph M. Becker
b9738f5802 Fix #79242: COM error constants don't match com_exception codes
Because a `HRESULT` is a `LONG`[1], no special treatment is required on
x86 platforms to get appropriate values.  On x64 platforms we prefer
positive values, what we could accomplish by casting the `HRESULT`
value to `ULONG` and then to `zend_long`, but since the current
behavior is correct and the performance improvement is negligible, we
defer that to master.

[1] <https://docs.microsoft.com/en-us/windows/win32/winprog/windows-data-types#hresult>
2020-02-07 18:04:14 +01:00
Christoph M. Becker
5e2ea00b15 Fix #66322: COMPersistHelper::SaveToFile can save to wrong location
Saving under the given `filename` may also work, but since
`::LoadFromFile` uses the `fullpath` we follow suit.
2020-02-06 14:59:55 +01:00
Christoph M. Becker
ce035dc4a0 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #78694: Appending to a variant array causes segfault
2019-10-19 11:49:18 +02:00
Christoph M. Becker
45a7723267 Fix #78694: Appending to a variant array causes segfault
`write_dimension` object handlers have to be able to handle `NULL`
`offset`s; for now we simply throw an exception instead of following
the `NULL` pointer.
2019-10-19 11:47:00 +02:00
Christoph M. Becker
a529826d95 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77578: Crash when php unload
2019-03-18 19:24:56 +01:00
Christoph M. Becker
41bc51ce2d Fix #77578: Crash when php unload
Since we're putting `ITypeLib *`s into the hash, we're getting
`ITypeLib *`s back, not `ITypeLib **`s.
2019-03-18 19:21:38 +01:00
Christoph M. Becker
767fa3dc02 Fix #77626: Persistence confusion in php_com_import_typelib()
We apply only the most minimal fix here, and will cater to the
unnecessary re-allocation for PHP-7.4.

We don't need to add a regression test, since bug39606.phpt and
bug77621.phpt already show the misbehavior.
2019-02-15 18:56:24 +01:00
Christoph M. Becker
8946ad3000 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77621: Already defined constants are not properly reported
2019-02-15 00:37:39 +01:00
Christoph M. Becker
de738496c2 Fix #77621: Already defined constants are not properly reported
We must not check uninitialized values (i.e. `c.value`), and we have to
use proper types for printf-style formats (i.e. `char *` instead of
`zend_string *`).
2019-02-15 00:35:21 +01:00
Christoph M. Becker
07d6dfbfe4 Use zend_empty_array
No need to define our own `com_dotnet_object_properties` as empty hash,
since we can use `zend_empty_array` instead as of PHP 7.3.0.

Cf. <https://github.com/php/php-src/pull/3672#issuecomment-440467704>.
2018-11-26 15:33:58 +01:00
Christoph M. Becker
b0a86566dc Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77177: Serializing or unserializing COM objects crashes
2018-11-23 16:36:00 +01:00
Christoph M. Becker
115ee49b0b Fix #77177: Serializing or unserializing COM objects crashes
Firstly, we avoid returning NULL from the get_property handler, but
instead return an empty HashTable, which already prevents the crashes.
Secondly, since (de-)serialization obviously makes no sense for COM,
DOTNET and VARIANT objects (at least with the current implementation),
we prohibit it right away.
2018-11-23 16:32:33 +01:00
Peter Kokot
b746e69887 Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:32:30 +02:00
Peter Kokot
f1d7e3ca0b Sync leading and final newlines in *.phpt sections
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines in all
*.phpt sections.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-15 04:31:31 +02:00
Peter Kokot
782352c54a Trim trailing whitespace in *.phpt 2018-10-14 19:45:12 +02:00
Peter Kokot
17ccbeec32 Trim trailing whitespace in *.phpt 2018-10-14 19:44:14 +02:00
Peter Kokot
1c850bfcca Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:55:24 +02:00
Peter Kokot
60a69daec6 Sync leading and final newlines in source code files
This patch adds missing newlines, trims multiple redundant final
newlines into a single one, and trims redundant leading newlines.

According to POSIX, a line is a sequence of zero or more non-' <newline>'
characters plus a terminating '<newline>' character. [1] Files should
normally have at least one final newline character.

C89 [2] and later standards [3] mention a final newline:
"A source file that is not empty shall end in a new-line character,
which shall not be immediately preceded by a backslash character."

Although it is not mandatory for all files to have a final newline
fixed, a more consistent and homogeneous approach brings less of commit
differences issues and a better development experience in certain text
editors and IDEs.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_206
[2] https://port70.net/~nsz/c/c89/c89-draft.html#2.1.1.2
[3] https://port70.net/~nsz/c/c99/n1256.html#5.1.1.2
2018-10-14 12:54:08 +02:00
Peter Kokot
902d39a3a7 Trim trailing whitespace in source code files 2018-10-13 14:14:50 +02:00
Anatol Belski
cd07fa48ba Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix callbacks
  bump version
2018-08-02 21:40:50 +02:00
Anatol Belski
91a0a10f71 Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Fix callbacks
  bump version
2018-08-02 21:20:04 +02:00
Anatol Belski
19592519c2 Fix callbacks
The signatures wasn't synced in 7.0
2018-08-02 18:59:34 +02:00
Anatol Belski
6059ecee3a Sync with ab8094c6 2018-07-26 13:58:08 +02:00
Peter Kokot
8d3f8ca12a Remove unused Git attributes ident
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.

In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.

This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
2018-07-25 00:53:25 +02:00
Kalle Sommer Nielsen
08f10ef47a Remove some dead code
sapi/*: Remove Windows code from FPM and LiteSpeed, as we don't support these SAPIs on Windows anyway
ext/com_dotnet: Remove non Windows code, as ext/com_dotnet is only supported on Windows
2018-07-23 15:26:39 +02:00
Dmitry Stogov
f2b4ec4bdc Export standard object handlers, to avoid indirect access 2018-05-31 11:57:22 +03:00
Dmitry Stogov
d90c6f2443 Removed useless zval_ptr_dtor() 2018-05-29 17:58:06 +03:00
Dmitry Stogov
5eb1f92f31 Use zend_string_release_ex() instread of zend_string_release() in places, where we sure about string persistence. 2018-05-28 16:27:12 +03:00
Anatol Belski
3aa030e7d9 Merge branch 'PHP-7.2'
* PHP-7.2:
  Sync fix for bug #72498 for 32-bit
2018-04-03 17:25:52 +02:00
Anatol Belski
2115878aaa Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Sync fix for bug #72498 for 32-bit
2018-04-03 17:25:13 +02:00
Anatol Belski
821f13fd79 Sync fix for bug #72498 for 32-bit 2018-04-03 17:24:13 +02:00
Gabriel Caruso
701437a948
Remove return types from some magic method in protos
__construct, __destruct, __wakeup does not have return types defined.
2018-03-09 12:04:46 +01:00
Nikita Popov
ede663f381 Convert iterator by reference errors to exceptions
I'm using RuntimeException in SPL, because other SPL classes that
throw this error used it. Error is used for everything else, because
that's what core does.
2018-02-19 21:58:56 +01:00
Gabriel Caruso
7566416d9d
Share identical arginfos 2018-02-19 08:31:03 +01:00
Gabriel Caruso
b0d3c1bf83 Add and fix SKIPIF sections 2018-02-04 17:26:37 +01:00
Gabriel Caruso
84488d921b Remove superfluous SKIPIF sections in more tests 2018-02-04 16:57:08 +01:00
Dmitry Stogov
5d456c1c66 Replaced separation with destructor 2018-01-17 03:01:00 +03:00