Commit graph

622 commits

Author SHA1 Message Date
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
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
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
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
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
9ed82b1f7b Fixed bug #79282 2020-03-16 22:42:15 -07:00
Stanislav Malyshev
b9d32197cb Fixed bug #79282 2020-03-16 22:40:48 -07:00
Stanislav Malyshev
25238bdf60 Fixed bug #79282 2020-03-16 22:40:00 -07: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
Máté Kocsis
99db00b1f2
Fix #78880 Another round 2020-01-19 18:28:43 +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
Nikita Popov
f0d1a27951 Merge branch 'PHP-7.4'
* PHP-7.4:
  Avoid float to int cast UB in exif
2019-12-17 13:26:32 +01:00
Nikita Popov
dd997a40d0 Avoid float to int cast UB in exif 2019-12-17 13:26:05 +01:00
Stanislav Malyshev
0dfff646a2 Merge branch 'PHP-7.4'
* PHP-7.4:
  Fix test
  Fix bug #78793
  Fix build - no model field anymore
  Fixed bug #78910
  Fix #78878: Buffer underflow in bc_shift_addsub
  Fix test
  Fix #78862: link() silently truncates after a null byte on Windows
  Fix #78863: DirectoryIterator class silently truncates after a null byte
  Fix #78943: mail() may release string with refcount==1 twice
2019-12-16 10:07:15 -08:00
Stanislav Malyshev
6b010b5d86 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix test
  Fix bug #78793
2019-12-16 10:05:02 -08:00
Stanislav Malyshev
5cb4686753 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix test
  Fix bug #78793
2019-12-16 10:04:03 -08:00
Stanislav Malyshev
c14eb8de97 Fix bug #78793 2019-12-16 01:14:58 -08:00
Stanislav Malyshev
c85a877577 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix build - no model field anymore
2019-12-16 01:11:01 -08:00
Stanislav Malyshev
b74a300edf Fix build - no model field anymore 2019-12-16 01:10:42 -08:00
Stanislav Malyshev
d9f57e8316 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fixed bug #78910
  Fix #78878: Buffer underflow in bc_shift_addsub
  Fix test
  Fix #78862: link() silently truncates after a null byte on Windows
  Fix #78863: DirectoryIterator class silently truncates after a null byte
  Fix #78943: mail() may release string with refcount==1 twice
2019-12-16 00:39:37 -08:00
Stanislav Malyshev
a65b8abf2c Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fixed bug #78910
  Fix #78878: Buffer underflow in bc_shift_addsub
  Fix test
  Fix #78862: link() silently truncates after a null byte on Windows
  Fix #78863: DirectoryIterator class silently truncates after a null byte
2019-12-16 00:38:54 -08:00
Stanislav Malyshev
d348cfb96f Fixed bug #78910 2019-12-16 00:10:39 -08:00
George Peter Banyard
761e8c7707 Remove dead commented code and dead code in-between KALLE_0 ifdefs.
Closes GH-4986
2019-12-08 20:21:40 +01:00
Nikita Popov
80cfd99074 Reduce reallocations in exif parsing
Instead of reallocating lists element by element, increase the
allocated list size exponentially.
2019-11-07 21:20:34 +01:00
Nikita Popov
49327e2e15 Merge branch 'PHP-7.4'
* PHP-7.4:
  Improve exif tag name fetching
  Implement a cache for exif tag name lookups
  Limit the amount of errors generated during exif parsing
2019-10-18 16:55:46 +02:00
Nikita Popov
650115c827 Improve exif tag name fetching 2019-10-18 16:55:05 +02:00
Nikita Popov
56e3e6f135 Implement a cache for exif tag name lookups 2019-10-18 16:54:56 +02:00
Nikita Popov
e5324a2484 Limit the amount of errors generated during exif parsing
Emitting errors is fairly expensive, to the point that parsing
a file with a huge number of invalid tags can take seconds.
Generating ten thousand errors is unlikely to help anybody, but
constitutes a potential DOS vector.
2019-10-18 16:54:49 +02:00
Nikita Popov
b53b2f3e82 Merge branch 'PHP-7.4' 2019-10-09 17:34:00 +02:00
Nikita Popov
5b44560dfc Merge branch 'PHP-7.3' into PHP-7.4 2019-10-09 17:33:52 +02:00
Nikita Popov
a0163417ef Merge branch 'PHP-7.2' into PHP-7.3 2019-10-09 17:33:44 +02:00
Nikita Popov
daf1fc6e31 Avoid float to int cast UB in exif 2019-10-09 17:33:29 +02:00
Nikita Popov
cb657440b4 Merge branch 'PHP-7.4' 2019-10-09 14:58:17 +02:00
Nikita Popov
a4d7f4c3e1 Merge branch 'PHP-7.3' into PHP-7.4 2019-10-09 14:58:10 +02:00
Nikita Popov
cbf589b17c Merge branch 'PHP-7.2' into PHP-7.3 2019-10-09 14:58:01 +02:00