1
0
mirror of https://github.com/php/php-src.git synced 2026-03-29 11:42:17 +02:00
Commit Graph

123588 Commits

Author SHA1 Message Date
Alex Dowad
cef4b94eef Code cleanup in mbfilter_utf7imap.c 2021-04-15 15:52:31 +02:00
Alex Dowad
8abc5e6827 Catch and handle errors in UTF-7 text conversion 2021-04-15 15:52:31 +02:00
Alex Dowad
689978a63b Code cleanup in mbfilter_utf7.c 2021-04-15 15:52:31 +02:00
Alex Dowad
ebe6500a0b Fix error reporting bug for Unicode -> CP50220 conversion
To detect errors in conversion from Unicode to another text encoding, each
mbstring conversion filter object maintains a count of 'bad' characters. After
a conversion operation finishes, this count is checked to see if there was any
error.

The problem with CP50220 was that mbstring used a chain of two conversion filter
objects. The 'bad character count' would be incremented on the second object in
the chain, but this didn't do anything, as only the count on the first such
object is ever checked.

Fix this by implementing the conversion using a single conversion filter object,
rather than a chain of two. This is possible because of the recent refactoring,
which pulled out the needed logic for CP50220 conversion into a helper function.
2021-04-15 15:52:31 +02:00
Alex Dowad
1f130d4e58 Refactor mbfl_filt_tl_jisx0201_jisx0208 by moving kana conversion into helper function
This will enable us to simplify the code for CP50220 conversion, which also relies
on this same kana conversion logic.
2021-04-15 15:52:31 +02:00
Alex Dowad
319a340843 Simplify code for working with halfwidth/fullwidth kana conversion filter
There's no need to dynamically allocate a struct to hold the 'mode' parameter;
just store it directly in `filt->opaque`. Some other things were also being done
in an unnecessarily roundabout way.

Also, the 'copy' function for CP50220 conversion filters was *both* broken
and unnecessary. Broken, because it malloc'd memory which was never freed by
anything. Unnecessary, because the point of the copy is so that various
algorithms can try running bytes through a conversion filter and see how many
output bytes or characters result, and then back out by restoring the filters
to their previous state. But here's the thing; CP50220 conversion filters don't
hold cached bytes, which is the main thing which would need to be restored to a
previous state.
2021-04-15 15:52:31 +02:00
Alex Dowad
a900ec3397 Remove unneeded 'filter_ctor' member from mbfl_convert_filter struct
This function pointer is only called when initializing the struct. After that
nothing is done with it. Therefore, there is no need to keep it in the struct.
2021-04-15 15:52:31 +02:00
Alex Dowad
affc3076f3 Remove unused 'next_filter' member from mbfl_filt_tl_jisx0201_jisx0208_param struct 2021-04-15 15:52:31 +02:00
Alex Dowad
636251a522 Remove useless function mbfl_filt_tl_jisx0201_jisx0208_init
This constructor function doesn't do anything different than the generic one.
There's no need to invoke it, either, when initializing a CP50220 conversion
filter.
2021-04-15 15:52:31 +02:00
Nikita Popov
b8942b8313 Fix test for older ICU versions
Apply the change that was done for variant7 to the other variants
as well.
2021-04-15 15:20:17 +02:00
Nikita Popov
41a28cea10 Merge branch 'PHP-8.0'
* PHP-8.0:
  Remove AMD64 jobs from Travis
2021-04-15 15:16:49 +02:00
Nikita Popov
d0fd118f9b Remove AMD64 jobs from Travis
We're only interested in the ARM64 and S390X jobs, x86 is already
extensively tested on Azure.
2021-04-15 15:16:18 +02:00
Nikita Popov
8e8dcf5f4c Implement debug_print_backtrace() on top of zend_fetch_backtrace()
As debug_print_backtrace() is not performance-critical, this
implements it by formatting the zend_fetch_backtrace() result.
This means there is only one place implementing the backtrace
construction logic, and they cannot go out of sync.
zend_fetch_backtrace() has much better test coverage, because
it is used by exceptions.

Closes GH-6869.
2021-04-15 15:15:20 +02:00
Dmitry Stogov
0fdf668dce Keep fci->object unchanged 2021-04-15 15:31:45 +03:00
Dmitry Stogov
ca49e53670 Stop inserting fake frames on VM stack.
Now similar "fake" frames now materialized when fetching debug
backtraces. The patch also fixes few incorrect backtraces for generators
in *.phpt tests.
2021-04-15 15:30:10 +03:00
Nikita Popov
7af3a392f1 Merge branch 'PHP-8.0'
* PHP-8.0:
  Handle ref return from Iterator::key()
2021-04-15 13:06:04 +02:00
Nikita Popov
46f9fed0d8 Handle ref return from Iterator::key()
Handle this in the implementation of get_current_key of user_it,
so that the callers may assume that the key is not a reference.

Fixes oss-fuzz #33018.
2021-04-15 13:05:48 +02:00
Nikita Popov
dfe8dbdc0d Destroy file handle earlier in execute fuzzer
I'm not quite sure why this is relevant, but if matches what other
code does and fixes oss-fuzz #32517.
2021-04-15 12:55:58 +02:00
Nikita Popov
25f23781a8 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix return-by-ref from array_reduce callback
2021-04-15 12:32:41 +02:00
Nikita Popov
f40c8fdf67 Fix return-by-ref from array_reduce callback
Fixes oss-fuzz #32990.
2021-04-15 12:32:05 +02:00
Nikita Popov
91b6895e79 Implement zend_print_flat_zval_r() using smart_str
Use the same implementation approach as for the non-flat
zend_print_zval_r() function.
2021-04-15 11:47:16 +02:00
twosee
1215563288 Micro optimizations for http_fopen_wrapper.c (#6864) 2021-04-15 16:34:17 +08:00
Nikita Popov
cf7f5cbfac mysqlnd: Free empty param bind
Even if the param bind is empty, there might still be an allocation
for it that we need to free.
2021-04-15 10:14:19 +02:00
Kamil Tekiela
14fd14d780 Silence the deprecation notice on var_dump 2021-04-14 13:47:48 +01:00
Kamil Tekiela
45bad6474e Mysqli bind in execute (#6271) 2021-04-14 12:52:51 +01:00
twosee
44a35c9219 Fix E_DEPRECATED in phar (#6824)
shell_exec() can return null both when an error occurs or the program produces no output, or return false when popen failed, and treating null/false as an empty string has no effect on the behavior of phar here.
2021-04-14 18:21:14 +08:00
Nikita Popov
b145256938 Fix type used in driver_reconnect_write
Now that the value is coerced to the correct type, we should be
treating this as a boolean, not an integer (treating it as an
integer was already incorrect before -- if people used the
property as documented they'd likely get garbage).
2021-04-14 09:58:15 +02:00
twosee
c457be80dd Merge branch 'PHP-8.0'
* PHP-8.0:
  Fixed bug #80900
2021-04-14 00:21:37 +08:00
twosee
a3e6735999 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fixed bug #80900

# Conflicts:
#	ext/opcache/Optimizer/sccp.c
2021-04-14 00:15:06 +08:00
twosee
7c6cf09463 Fixed bug #80900
SCCP optimization marks the wrong target feasible when the constant is of the incorrect type.

Closes GH-6861.
2021-04-14 00:07:32 +08:00
Christoph M. Becker
bebb0b7bbe Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #80933: SplFileObject::DROP_NEW_LINE is broken for NUL and CR
2021-04-13 16:50:15 +02:00
Christoph M. Becker
80f921d7e0 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #80933: SplFileObject::DROP_NEW_LINE is broken for NUL and CR
2021-04-13 16:49:57 +02:00
Christoph M. Becker
976e71a2fa Fix #80933: SplFileObject::DROP_NEW_LINE is broken for NUL and CR
`buf` may contain NUL bytes, so we must not use `strcspn()` but rather
a binary safe variant.  However, we also must not detect a stray CR as
line ending, and since we only need to check line endings at the end
of the buffer, we can nicely optimize.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-6836.
2021-04-13 16:49:06 +02:00
Nikita Popov
91908bcd52 Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix function/file mixup in backtrace printing
2021-04-13 16:34:17 +02:00
Levi Morrison
6fd13d0afd Fix function/file mixup in backtrace printing
The error says "Function name" is not a string, but it's actually
investigating the "file" field, not "function".

Closes GH-6768.
2021-04-13 16:33:30 +02:00
David Gebler
cbcfd86026 Add fsync() and fdatasync() functions
fsync is a straightforward wrapper around the same C function
(implemented on Windows API as _commit() with identical signature).

From the man pages:

    fsync() transfers ("flushes") all modified in-core data of (i.e.,
    modified buffer cache pages for) the file referred to by the file
    descriptor fd to the disk device (or other permanent storage
    device) so that all changed information can be retrieved even if
    the system crashes or is rebooted.  This includes writing through
    or flushing a disk cache if present.  The call blocks until the
    device reports that the transfer has completed.

RFC: https://wiki.php.net/rfc/fsync_function

Closes GH-6650.
2021-04-13 16:09:22 +02:00
Nikita Popov
0c5711856f Add zend_ulong_to_str() API
No point in going through a smart_str and append_unsigned if we
can construct the result directly...
2021-04-13 15:56:24 +02:00
Nikita Popov
65a5c184d7 Add functions to convert i64/u64 to string
PDO implement half of this, but this functionality is generally
useful. Provide these as zend_u64_to_str and zend_i64_to_str to
complement zend_long_to_str.
2021-04-13 15:43:23 +02:00
Nikita Popov
0e7b4d09ec Add tests for mysqli property writing
Forgot to git add these in the previous commit.
2021-04-13 15:32:49 +02:00
Nikita Popov
d905e77483 Enforce types when writing to mysqli dynamic properties
Previously this just assumed that the value was of a certain type.

I'm doing this in a generic way that checks against the declared
property type -- the handler function can then assume the value
to be of the correct type.
2021-04-13 15:30:56 +02:00
Dmitry Stogov
0fc3818cc5 Initialize fast class cache 2021-04-13 15:54:02 +03:00
Nikita Popov
0c7cdbbaba Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix return type of sparc atomic helper
2021-04-13 14:37:26 +02:00
Nikita Popov
ec24f14820 Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix return type of sparc atomic helper
2021-04-13 14:37:18 +02:00
David Carlier
5ccb5fd91e Fix return type of sparc atomic helper
Closes GH-6808.
2021-04-13 14:36:58 +02:00
Dmitry Stogov
a439d9f232 Call zend_generator_check_placeholder_frame() only for frames with
ZEND_CALL_GENERATOR flag
2021-04-13 15:25:05 +03:00
Derick Rethans
7bd0b1078b Merge branch 'PHP-8.0' 2021-04-13 11:50:28 +01:00
Derick Rethans
f20ca94b1c Merge branch 'PHP-7.4' into PHP-8.0 2021-04-13 11:50:20 +01:00
Derick Rethans
f99926f554 Put back inadvertedly removed NEWS entries 2021-04-13 11:48:50 +01:00
Gabriel Caruso
79872ac9c2 8.0.6 is the next version 2021-04-13 12:41:21 +02:00
Derick Rethans
be533a35c1 Merge branch 'PHP-8.0' 2021-04-13 11:35:09 +01:00