Commit Graph

791 Commits

Author SHA1 Message Date
Máté Kocsis
4f42519571
Review parameter names in ext/exif
Closes GH-6256
2020-10-02 11:56:16 +02:00
Nikita Popov
c5401854fc Run tidy
This should fix most of the remaining issues with tabs and spaces
being mixed in tests.
2020-09-18 14:28:32 +02:00
Nikita Popov
7e339a335e Make null byte error a ValueError
Currently we treat paths with null bytes as a TypeError, which is
incorrect, and rather inconsistent, as we treat empty paths as
ValueError. We do this because the error is generated by zpp and
it's easier to always throw TypeError there.

This changes the zpp implementation to throw a TypeError only if
the type is actually wrong and throw ValueError for null bytes.
The error message is also split accordingly, to be more precise.

Closes GH-6094.
2020-09-08 15:23:23 +02:00
Nikita Popov
259af931e6 Promote warnings in exif
The only thing that can promoted are the path-related checked.
Everything else is input dependent and error-suppressing these
functions is both the typical and the recommended usage.
2020-09-08 11:51:19 +02:00
Nikita Popov
d1ac7e3ab1 Remove some unnecessary HAVE_EXTNAME guards
A recurring pattern in old extension: Putting the whole source
code behind HAVE_EXTNAME. This is pointless, as the code is only
compiled if the extension is enabled.

This removes a couple of them, but not all.
2020-09-07 11:05:07 +02:00
Nikita Popov
5f4b169be8 Merge branch 'PHP-7.4'
* PHP-7.4:
  Make MAX_IFD_NESTING_LEVEL an actual nesting level
2020-08-31 09:36:48 +02:00
Nikita Popov
c45985d266 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Make MAX_IFD_NESTING_LEVEL an actual nesting level
2020-08-31 09:32:55 +02:00
Nikita Popov
376bbbdf3b Make MAX_IFD_NESTING_LEVEL an actual nesting level
Currently we only ever increment ifd_nesting_level, so this ends up
being a limit on the total number of IFD tags and we regularly get
bug reports of it being exceeded. I think the intention behind this
limit was to prevent recursion stack overflow, and for that we only
need to check actual recursive usage. I've implemented that here,
and dropped the nesting limit down to a smaller value
(which still passes our tests).

However, it seems that we do also need to have a total limit on
the number of tags, as we don't catch some instances of infinite
looping otherwise. Add this as a separate limit with a higher
value, that should hopefully be sufficient.

This is expected to fix a number of bugs:

https://bugs.php.net/bug.php?id=78083
https://bugs.php.net/bug.php?id=78701
https://bugs.php.net/bug.php?id=79907
https://bugs.php.net/bug.php?id=80016
2020-08-31 09:28:59 +02:00
Nikita Popov
8694eb14f4 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #75785 by attempt switching endianness on Maker's Note
2020-08-11 16:29:01 +02:00
Nikita Popov
5c5508698d Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix bug #75785 by attempt switching endianness on Maker's Note
2020-08-11 16:27:06 +02:00
Nawarian
2fa4ca95db Fix bug #75785 by attempt switching endianness on Maker's Note
Different manufacturer models may come with a
different endianness (motorola/intel) format. In
order to avoid a big refactor and a gigantic lookup
table, this commit simply attempts to switch the
endianness and proceed when values are acceptable.

Closes GH-5849.
2020-08-11 16:26:34 +02:00
Máté Kocsis
7aacc705d0
Add many missing closing PHP tags to tests
Closes GH-5958
2020-08-09 22:03:36 +02:00
Máté Kocsis
046cc5e4c2
Add another round of missing parameter types to stubs
Closes GH-5950
2020-08-07 16:48:45 +02:00
Máté Kocsis
bdacd2ae8f
Add a few missing types to stubs 2020-08-01 23:55:08 +02:00
Nikita Popov
e59efb3740 Put debug function behind ifdef 2020-07-13 17:24:31 +02:00
Nikita Popov
2d98f0cad2 Restore warning 2020-07-13 14:40:19 +02:00
Nat Wyatt
6f48ccf51c Fix compilation errors when EXIF_DEBUG is defined
Fix warnings and error when compiling with EXIF_DEBUG defined.

Closes GH-5838.
2020-07-13 11:00:02 +02:00
Max Semenik
2b5de6f839
Remove proto comments from C files
Closes GH-5758
2020-07-06 21:13:34 +02:00
Fabien Villepinte
0c6d06ecfa Replace EXPECTF when possible
Closes GH-5779
2020-06-29 21:31:44 +02:00
Máté Kocsis
b5c7a83dca
Remove unnecessary PHPDoc-alike blocks from tests
Closes GH-5759
2020-06-24 13:13:44 +02:00
Nikita Popov
c9b9f525a9 Include stub hash in generated arginfo files
The hash is used to check whether the arginfo file needs to be
regenerated. PHP-Parser will only be downloaded if this is actually
necessary.

This ensures that release artifacts will never try to regenerate
stubs and thus fetch PHP-Parser, as long as you do not modify any
files.

Closes GH-5739.
2020-06-24 09:55:19 +02:00
George Peter Banyard
6079bdb287 Use standard bool type in EXIF extension 2020-06-23 20:57:26 +02:00
Christoph M. Becker
63cb47a86b Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix #79687: Sony picture - PHP Warning - Make, Model, MakerNotes
2020-06-13 18:33:17 +02:00
Christoph M. Becker
59e343c779 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #79687: Sony picture - PHP Warning - Make, Model, MakerNotes
2020-06-13 18:32:15 +02:00
Christoph M. Becker
5621c5faf8 Fix #79687: Sony picture - PHP Warning - Make, Model, MakerNotes
Even if the length of a maker note does not match our expectations
(either because the maker note is corrupted, or because our
expectations do not quite match reality), there is no need to let
parsing fail; we can still go on parsing the other meta information.
2020-06-13 18:30:57 +02:00
Nikita Popov
4f9a1122e1 Avoid out of range float to int cast in exif
Use convert_any_int instead of convert_any_format to directly get
an integer.

Also adjust SRATIONAL handling to not go through a double division.
This was introduced to avoid SIGFPE for the INT_MIN / -1 case,
but we can just handle that explicitly.
2020-06-12 12:54:41 +02:00
Nikita Popov
f68a64a8a8 Fix null pointer UB in add_assoc_image_info()
And clean up this function a bit by reducing indentation and
variable scope.
2020-06-12 10:56:54 +02:00
Nikita Popov
ece375052b Fix float conversion warning
We are okay with the loss of precision here...
2020-06-12 10:20:10 +02:00
George Peter Banyard
fb5114c675 Fix [-Wundef] warning in Filter extension 2020-05-16 15:31:16 +02:00
George Peter Banyard
e37501e6c7 Fix [-Wundef] warning in EXIF extension 2020-05-16 15:31:16 +02:00
Nikita Popov
810c5c74e6 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix bug #79336
2020-04-16 12:18:50 +02:00
Nikita Popov
0b709e3409 Fix bug #79336
Make reading of floats and doubles host-endian independent.
2020-04-16 12:18:41 +02:00
Máté Kocsis
3709e74b5e
Store default parameter values of internal functions in arg info
Closes GH-5353. From now on, PHP will have reflection information
about default values of parameters of internal functions.

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2020-04-08 18:37:51 +02:00
Máté Kocsis
7c3078737f
Generate function entries from stubs for a couple of extensions
Closes GH-5347
2020-04-04 20:41:48 +02:00
Christoph M. Becker
ea7cf2eb67 Merge branch 'PHP-7.4'
* PHP-7.4:
  [ci skip] Update NEWS
  Fix test
  Fix bug #79329 - get_headers should not accept \0
  Fixed bug #79282
  Fix #79283: Segfault in libmagic patch contains a buffer overflow
  Fix #79371: mb_strtolower (UTF-32LE): stack-buffer-overflow
  [ci skip] Update NEWS
  Fix test
  Fix bug #79329 - get_headers should not accept \0
  Fixed bug #79282
  Fix #79371: mb_strtolower (UTF-32LE): stack-buffer-overflow
2020-03-17 10:33:28 +01:00
Stanislav Malyshev
03bf4edbe8 Fix test 2020-03-16 22:42:15 -07:00
Stanislav Malyshev
9ed82b1f7b Fixed bug #79282 2020-03-16 22:42:15 -07:00
Stanislav Malyshev
1599f440a5 Fix test 2020-03-16 22:40:48 -07:00
Stanislav Malyshev
b9d32197cb Fixed bug #79282 2020-03-16 22:40:48 -07:00
Stanislav Malyshev
62e7b80267 Fix test 2020-03-16 22:40:00 -07:00
Stanislav Malyshev
25238bdf60 Fixed bug #79282 2020-03-16 22:40:00 -07:00
Nikita Popov
a939805641 Use serialize_precision for var_dump()
var_dump() is debugging functionality, so it should print
floating-point numbers accurately. We do this by switching
to serialize_precision, which (by default) will print with
as much precision as necessary to preserve the exact value
of the float.

This also affects debug_zval_dump().

Closes GH-5172.
2020-02-25 09:51:32 +01:00
Nikita Popov
7a062cf9cd Handle EXIF offsets in a principled manner
exif_process_IFD_TAG() currently accepts a dir_entry, offset_base
and IFDlength. However, it's very hard to follow how these values
are related to each other and the addressable memory region. As we
add additional bounds check, this gets further confused.

One of the basic cases is where dir_entry is in
[offset_base, offset_base+IFDlength), in which case the memory
[dir_entry, offset_base+IFDlength) is valid, but the memory
[offset_base, dir_entry) is not necessarily valid. I wasn't able
to understand what exactly is valid if dir_entry is outside
[offset_base, offset_base+IFDlength)

This patch changes everything to use a struct that separately stores
offset_base and the valid memory region and adds helpers to fetch
offsets and check that pointers are in-bounds.

Closes GH-5068.
2020-02-18 15:17:38 +01:00
Nikita Popov
f8d795820e Reindent phpt files 2020-02-03 22:52:20 +01:00
Máté Kocsis
99db00b1f2
Fix #78880 Another round 2020-01-19 18:28:43 +01:00
Máté Kocsis
d1764ca330
Make error messages more consistent by fixing capitalization
Closes GH-5066 As a first step, let's capitalize their initial letter when it is applicable.
2020-01-17 14:52:46 +01:00
Máté Kocsis
7b4a4d2ace
Use RETURN_THROWS() after try_convert_to_string() 2020-01-03 17:04:06 +01:00
Máté Kocsis
382a038e05
Use ZEND_THROWS() during ZPP in enchant, exif, fileinfo, filter, and FTP extensions 2019-12-31 00:21:37 +01:00
Nikita Popov
d21ad4d955 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fixed bug #79046
2019-12-30 17:24:16 +01:00
Nikita Popov
d1537e506e Fixed bug #79046 2019-12-30 17:23:53 +01:00