Commit graph

449 commits

Author SHA1 Message Date
Saki Takamachi
12dc51976b
ext/hash: Swap the checking order of __has_builtin and __GNUC__ (#14185)
closes #14185
2024-05-10 09:37:13 +09:00
Niels Dossche
2ee4d358dc Fix 32-bit ext/hash build 2023-12-13 19:33:09 +01:00
Niels Dossche
2b8c00850b Fix GH-12936: hash() function hangs endlessly if using sha512 on strings >= 4GiB
There's two problems:
- Some loops used `unsigned int` instead of `size_t`.
- The 2*N-bit addition that is emulated using 2 N bit numbers has a bug:
  it first truncated the number to 32/64 bit and only then shifted. This
  resulted in the wrong length info stored inside the resulting hash.

Closes GH-12937.
2023-12-12 19:57:06 +01:00
Niels Dossche
5df473d2c7 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-12223: Entity reference produces infinite loop in var_dump/print_r
  Fix GH-12192: SimpleXML infinite loop when getName() is called within foreach
  Fix GH-12186: segfault copying/cloning a finalized HashContext
2023-09-16 21:24:20 +02:00
Max Semenik
10f5a06d3c Fix GH-12186: segfault copying/cloning a finalized HashContext
Closes GH-12186.
Closes GH-12187.
2023-09-16 21:18:27 +02:00
Ilija Tovilo
e8c9c73118
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix hash_pbkdf2 options parameter
2023-07-18 19:23:10 +02:00
Ilija Tovilo
7cae6eb8db
Fix hash_pbkdf2 options parameter
The value needs to be initialized to NULL as it is optional. Furthermore, the
parameter was completely missing in the stub signature.

Closes GH-11731
2023-07-18 19:21:13 +02:00
Niels Dossche
e6730565b6 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11180: hash_file() appears to be restricted to 3 arguments
2023-05-07 17:37:25 +02:00
Niels Dossche
baa07f3de3 Fix GH-11180: hash_file() appears to be restricted to 3 arguments
Closes GH-11198.
2023-05-07 17:33:28 +02:00
David Carlier
7638640529 Fix GH-10659: hash/xxhash applying build upstream fix
ref: 6189ecd3d4

replacing the C++ compile time assert for C11 one.

Closes GH-10693.
2023-02-25 14:36:35 +00:00
George Peter Banyard
dd5c5ca7a5
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Handle exceptions from __toString in XXH3's initialization
  Fix phpdbg segmentation fault in case of malformed input
2023-01-17 14:16:18 +00:00
Niels Dossche
7463e70b1e
Handle exceptions from __toString in XXH3's initialization
The initialization routine for XXH3 was not prepared for exceptions from seed.
Fix this by using try_convert_to_string.

For discussion, please see: GH-10305

Closes GH-10352

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-17 14:14:12 +00:00
Mattias Ellert
a83923044c
Fix compilation on RHEL 7 ppc64le (gcc 4.8)
Fixes GH-10077
Closes GH-10078
2022-12-11 17:30:31 +01:00
Stanislav Malyshev
acbd5c1164 Merge branch 'PHP-8.1' into PHP-8.2 2022-10-21 00:05:35 -06:00
Stanislav Malyshev
27aed8f345 Merge branch 'PHP-8.0' into PHP-8.1 2022-10-21 00:05:30 -06:00
Stanislav Malyshev
beff4278a4 Merge branch 'PHP-7.4' into PHP-8.0 2022-10-21 00:04:43 -06:00
Stanislav Malyshev
248f647724 Fix bug #81738 (buffer overflow in hash_update() on long parameter) 2022-10-20 23:57:35 -06:00
Máté Kocsis
b4ec3e9bc0
Do not generate CONST_CS when registering constants (#9439) 2022-08-28 08:27:19 +02:00
Máté Kocsis
e328c68305
Rename @cname to @cvalue in stubs (#9043)
@cname currently refers to the constant name in C. However, it is not always a (constant) name, but sometimes a function invocation, so naming it as @cvalue would be more appropriate.
2022-07-19 15:11:42 +02:00
Derick Rethans
7db9c2a2c3 Fixed typo in configure message 2022-07-18 15:18:08 +01: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
David Carlier
bfe6f9e66a Introduction of timing attack safe bcmp implementation.
Nothing new but to refactor usage b/w hash and password
extensions but using volatile pointers to be a bit safer,
allowing to expand its usage eventually.
2022-06-20 16:30:30 +01:00
Pierrick Charron
6fd2b39397
Indent with TAB in .h files generated by gen_stub 2022-06-13 08:55:54 -04:00
Tim Düsterhus
0d4147f0fb Mark parameter in ext/hash as sensitive 2022-06-13 11:09:12 +02:00
Máté Kocsis
debd38f851 Add support for sensitive parameters in stubs 2022-06-04 18:15:05 +02:00
Máté Kocsis
59ae6a9ff3
Declare HASH_HMAC in stubs 2022-06-04 11:22:44 +02:00
Christoph M. Becker
012ef7912a
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #81714: segfault when serializing finalized HashContext
2022-04-05 13:36:50 +02:00
Christoph M. Becker
187f5a362d
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #81714: segfault when serializing finalized HashContext
2022-04-05 13:36:07 +02:00
Christoph M. Becker
c2eafc29f5
Fix #81714: segfault when serializing finalized HashContext
We must not allow to serialize already finalized `HashContext`s, since
the internal context is already freed.  Since there is not much point
in serializing finalized `HashContext`s, we just bail out in that case.

Closes GH-8265.
2022-04-05 13:25:22 +02:00
Christoph M. Becker
77b54248c8
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-7826: Inconsistent argument name in hash_hmac_file and hash_file
2021-12-26 12:59:38 +01:00
Christoph M. Becker
a6ddd1a14d
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-7826: Inconsistent argument name in hash_hmac_file and hash_file
2021-12-26 12:59:06 +01:00
Christoph M. Becker
fd3fc5c193
Fix GH-7826: Inconsistent argument name in hash_hmac_file and hash_file
Like `hash_file()`, `hash_hmac_file()` expects a filename, and not some
string data.  Fixing this now, constitutes a (hopefully small) BC break
though.

Closes GH-7828.
2021-12-26 12:55:53 +01:00
Anatol Belski
28287572a1
hash: Upgrade xxHash to 0.8.1
Signed-off-by: Anatol Belski <ab@php.net>
2021-12-25 19:00:09 +01:00
Christoph M. Becker
fe2c13cda4
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix GH-7759: Incorrect return types for hash() and hash_hmac()
2021-12-12 15:47:39 +01:00
Christoph M. Becker
a708db9c8a
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix GH-7759: Incorrect return types for hash() and hash_hmac()
2021-12-12 15:47:19 +01:00
Christoph M. Becker
0b3a937670
Fix GH-7759: Incorrect return types for hash() and hash_hmac()
`hash()` and `hash_hmac()` never return `false`; only `hash_file()` and
`hash_hmac_file()` return `false` in case the data cannot be read.

Closes GH-7760.
2021-12-12 15:39:55 +01:00
Remi Collet
bc9d604430
Merge branch 'PHP-8.1'
* PHP-8.1:
  fix [-Wstrict-prototypes] buid warnings
2021-11-24 14:55:30 +01:00
Remi Collet
ef2fd0e5b5
fix [-Wstrict-prototypes] buid warnings 2021-11-24 14:55:11 +01:00
Dmitry Stogov
90b7bde615 Use more compact representation for packed arrays.
- for packed arrays we store just an array of zvals without keys.
- the elements of packed array are accessible throuf as ht->arPacked[i]
  instead of ht->arData[i]
- in addition to general ZEND_HASH_FOREACH_* macros, we introduced similar
  familied for packed (ZEND_HASH_PACKED_FORECH_*) and real hashes
  (ZEND_HASH_MAP_FOREACH_*)
- introduced an additional family of macros to access elements of array
  (packed or real hashes) ZEND_ARRAY_ELEMET_SIZE, ZEND_ARRAY_ELEMET_EX,
  ZEND_ARRAY_ELEMET, ZEND_ARRAY_NEXT_ELEMENT, ZEND_ARRAY_PREV_ELEMENT
- zend_hash_minmax() prototype was changed to compare only values

Because of smaller data set, this patch may show performance improvement
on some apps and benchmarks that use packed arrays. (~1% on PHP-Parser)

TODO:
    - sapi/phpdbg needs special support for packed arrays (WATCH_ON_BUCKET).
    - zend_hash_sort_ex() may require converting packed arrays to hash.
2021-11-03 15:18:26 +03:00
Máté Kocsis
fdc6082902
Generate optimizer func info from stubs for various extensions (#7409)
ext/hash, ext/iconv, ext/mbstring, ext/xml, ext/zlib
2021-08-26 19:52:11 +02:00
Nikita Popov
bf0c1ce1a0 Deprecate mhash
Deprecate mhash(), mhash_keygen_s2k(), mhash_count(),
mhash_get_block_size() and mhash_get_hash_name() in favor of the
normal hash_*() functions.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
2021-07-08 15:34:51 +02:00
Patrick Allaert
aff365871a Fixed some spaces used instead of tabs 2021-06-29 11:30:26 +02:00
Nikita Popov
7485978339
Migrate SKIPIF -> EXTENSIONS (#7138)
This is an automated migration of most SKIPIF extension_loaded checks.
2021-06-11 11:57:42 +02:00
Nikita Popov
050e13c55e Use free_obj handler in HashContext
Instead of dtor_obj.
2021-06-09 12:12:13 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
George Peter Banyard
dcdc5d9069 Drop -Wno-implicit-fallthrough compiler flag
And add it back to ext/date, ext/hash, and ext/opcache
2021-04-19 13:59:18 +01:00
Anatol Belski
e0e3d9851a hash: Fix -Warray-parameter= warnings
Signed-off-by: Anatol Belski <ab@php.net>
2021-03-26 23:29:01 +01:00
Anatol Belski
8ff6dbb57c hash: xxhash: Use canonicalization routine from existing API
Signed-off-by: Anatol Belski <ab@php.net>
2021-03-13 21:38:10 +01:00
Anatol Belski
20501c72c8 hash: Implement secret support for xxh3 and xxh128
A secret can be passed through the options array. The length is
currently in the range of 136 to 256 bytes. The concerned algos are
already marked as non serializable.

Signed-off-by: Anatol Belski <ab@php.net>
2021-02-20 23:26:59 +01:00