Commit graph

693 commits

Author SHA1 Message Date
Christoph M. Becker
ec591b555f Change gdImageTrueColorToPalette() to return success/failure
We're porting the relevant changes from
<34a00a40>.

We also check the return value in the PHP binding, and throw E_WARNING if
the conversion failed.
2016-10-03 12:02:31 +02:00
Christoph M. Becker
2a305b38b7 Implement request #33066: Add GD Image Function gdImageOpenPolygon()
gdImageOpenPolygon() has been introduced with líbgd 2.0.29, so we finally
add a PHP binding for it, and port the respective libgd functionality to
PHP's bundled libgd.
2016-10-02 20:27:58 +02:00
Christoph M. Becker
82a8e57f37 Add support for gdEffectMultiply
gdLayerMultiply() has been introduced in libgd 2.1.1, and as such would have
been already available for imagelayereffect() with a system libgd. We port
the respective code to the bundled libgd, and also make IMG_EFFECT_MULTIPLY
available to userland.
2016-10-02 19:10:13 +02:00
Christoph M. Becker
d0f14a4429 Switch to libgd anti-aliased drawing API
Instead of rolling our own in the bundled libgd, we use libgd's anti-aliased
drawing API. This way imageantialias() is also available, when built against
a system libgd.
2016-10-02 13:16:40 +02:00
Christoph M. Becker
65ee87f20d Refactor imagegammacorrect()
We apply the law `(b**r)**s == b**(r*s)` which holds for all non-negative b
and positive r,s, so a single pow() suffices. Furthermore, we precompute the
gamma, so the refactored code is simpler and faster.
2016-09-25 11:28:39 +02:00
Christoph M. Becker
2e1d20a28b Merge branch 'pull-request/2026' 2016-09-24 15:41:55 +02:00
Christoph M. Becker
d95b8eaf31 Don't enforce palette conversion when writing GD images
The GD image format is able to handle truecolor images as of libgd 2.0.12
(<https://github.com/libgd/libgd/blob/gd-2.2.3/src/gd_gd.c#L31-L33>).
Therefore we don't need the potentially lossy and time consuming palette
conversion.

This way, imagegd() can also be used to export raw truecolor image data.
2016-09-24 14:46:37 +02:00
Christoph M. Becker
1da79a6c6e Fix #73157 (again): imagegd2() ignores 3rd param if 4 are given
Obviously, there was a bad merge.
2016-09-24 00:35:24 +02:00
Christoph M. Becker
9482932251 Merge branch 'PHP-7.1' 2016-09-24 00:13:36 +02:00
Christoph M. Becker
bf66af1d60 Merge branch 'PHP-7.0' into PHP-7.1 2016-09-24 00:07:50 +02:00
Christoph M. Becker
456be3ec37 Merge branch 'PHP-5.6' into PHP-7.0 2016-09-23 23:46:22 +02:00
Christoph M. Becker
c240978067 Fix #73157: imagegd2() ignores 3rd param if 4 are given
We must initialize `q` for *more* than three parameters, too.
2016-09-23 23:42:34 +02:00
Christoph M. Becker
dc59aafa77 Merge branch 'PHP-7.1' 2016-09-20 01:38:28 +02:00
Christoph M. Becker
474428943f Merge branch 'PHP-7.0' into PHP-7.1 2016-09-20 01:32:32 +02:00
Christoph M. Becker
ba2d9e1ff1 Merge branch 'PHP-5.6' into PHP-7.0 2016-09-20 01:25:08 +02:00
Christoph M. Becker
fc2cadca2d Merge branch 'pull-request/1845' into PHP-5.6 2016-09-20 01:05:57 +02:00
Andrea Faulds
3cc9090101 Remove remaining zpp fallback code (master branch)
Follow-up to d690014bf3
2016-09-11 22:50:24 +01:00
Stanislav Malyshev
6e7d4fdde4 Merge branch 'PHP-7.1'
* PHP-7.1:
  Change the name of the second parameter of image writer functions
2016-09-05 00:43:52 -07:00
Christoph M. Becker
f203de0748 Change the name of the second parameter of image writer functions
As of PHP 5.4.0 the second parameter of all image writer functions (except
imagexbm) accepts also a stream resource. Therefore the parameter name
`filename` is inappropriate. We change it to `to` according to what it's
already called in _php_image_output_ctx().

We consider the reflection only related BC break acceptable for a minor version.
2016-09-05 00:43:30 -07:00
Christoph M. Becker
af69021f67 Merge branch 'PHP-7.1' 2016-09-03 14:01:39 +02:00
Christoph M. Becker
9eeb705eca Merge branch 'PHP-7.0' into PHP-7.1 2016-09-03 13:53:07 +02:00
Christoph M. Becker
0bc7e0c0ce Merge branch 'PHP-5.6' into PHP-7.0 2016-09-03 13:46:03 +02:00
Christoph M. Becker
bca913d70a Fix proto comment
While we're at it, we also change a related comment to use American English
consistently.
2016-09-03 13:41:29 +02:00
Christoph M. Becker
0bf11d1e71 Implement FAST_ZPP support for imagecolorat() and imagesetpixel()
These functions may be used in tight loops to do image manipulation in
userland. Using FAST_ZPP is supposed to bring considerable performance
improvements in this case; we've been able to measure up to 25%.
2016-09-02 19:06:26 +02:00
Christoph M. Becker
2c74a5282e Merge branch 'PHP-7.1' 2016-08-21 20:04:18 +02:00
Christoph M. Becker
5347246f56 Merge branch 'PHP-7.0' into PHP-7.1 2016-08-21 19:55:09 +02:00
Christoph M. Becker
4c13a7f5c4 Merge branch 'PHP-5.6' into PHP-7.0 2016-08-21 19:48:38 +02:00
Christoph M. Becker
6a232c3604 Fix #68716: possible resource leaks in _php_image_convert()
We properly clean up after ourselves wrt. to closing opened file pointers
and created images.
2016-08-21 19:39:58 +02:00
Xinchen Hui
660d8f1622 Merge branch 'PHP-7.1'
* PHP-7.1: (49 commits)
  Update NEWs
  Update NEWs
  Unused label
  Fixed bug #72853 (stream_set_blocking doesn't work)
  fix test
  Bug #72663 - part 3
  Bug #72663 - part 2
  Bug #72663 - part 1
  Update NEWS
  BLock test with memory leak
  fix tests
  Fix TSRM build
  Fix bug #72850 - integer overflow in uuencode
  Fixed bug #72849 - integer overflow in urlencode
  Fix bug #72848 - integer overflow in quoted_printable_encode caused heap corruption
  Fix bug #72838 - 	Integer overflow lead to heap corruption in sql_regcase
  Fix bug #72837 - integer overflow in bzdecompress caused heap corruption
  Fix bug #72836 - integer overflow in base64_decode caused heap corruption
  Fix for bug #72807 - do not produce strings with negative length
  Fix for bug #72790 and bug #72799
  ...
2016-08-17 17:15:11 +08:00
Xinchen Hui
ce6ad9bdd9 Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: (48 commits)
  Update NEWs
  Unused label
  Fixed bug #72853 (stream_set_blocking doesn't work)
  fix test
  Bug #72663 - part 3
  Bug #72663 - part 2
  Bug #72663 - part 1
  Update NEWS
  BLock test with memory leak
  fix tests
  Fix TSRM build
  Fix bug #72850 - integer overflow in uuencode
  Fixed bug #72849 - integer overflow in urlencode
  Fix bug #72848 - integer overflow in quoted_printable_encode caused heap corruption
  Fix bug #72838 - 	Integer overflow lead to heap corruption in sql_regcase
  Fix bug #72837 - integer overflow in bzdecompress caused heap corruption
  Fix bug #72836 - integer overflow in base64_decode caused heap corruption
  Fix for bug #72807 - do not produce strings with negative length
  Fix for bug #72790 and bug #72799
  Fix bug #72730 - imagegammacorrect allows arbitrary write access
  ...

Conflicts:
	ext/standard/var_unserializer.c
2016-08-17 17:14:30 +08:00
Stanislav Malyshev
1bd103df00 Fix bug #72730 - imagegammacorrect allows arbitrary write access 2016-08-16 22:55:40 -07:00
Stanislav Malyshev
a3598dd7c9 Fix bug#72697 - select_colors write out-of-bounds 2016-08-16 22:55:40 -07:00
Anatol Belski
28022c9b1f Fix bug#72697 - select_colors write out-of-bounds
(cherry picked from commit b6f13a5ef9d6280cf984826a5de012a32c396cd4)

Conflicts:
	ext/gd/gd.c
2016-08-16 14:37:39 +02:00
Stanislav Malyshev
e70069a62f Fix bug #72730 - imagegammacorrect allows arbitrary write access
(cherry picked from commit 047fe0ed03093a496691d376fcf51a7e2f1d04b0)

Conflicts:
	ext/gd/gd.c
2016-08-16 14:14:03 +02:00
Kalle Sommer Nielsen
36b050c2c5 Get rid of these slow calls to LoadLibrary()/GetProcAddress() calls on Windows, we require Windows Vista as bare minimum for PHP anyway, so it does not make any sense to do this slow emulation anyway.
GD:
 - PrintWindow() is available as of Windows XP, it requires linking to User32.lib, which config.w32 for ext/gd already.

CLI:
 - The borrowed functions from PostgreSQL to set the titles of the console window uses SetConsoleTitle() and GetConsoleTitle(), both are available as of Windows 2000 from Kernel32.lib which we already are linking against.

Standard:
 - The disk space utility functions uses GetDiskFreeSpaceExA() which is available as of Windows XP, again links to Kernel32.lib.
 - The symlink() PHP function uses CreateSymbolicLinkA() which is available from Windows Vista, again from Kernel32.lib.
 - php_get_windows_name() in info.c uses GetNativeSystemInfo() which is available as of Windows XP and GetProductInfo() which is available as of Windows Vista, both are again from Kernel32.lib.

Notes:
 - ext/interbase & ext/pdo_firebird uses GetProcAddress(), I'm not entirely sure how to handle this one.
 - ext/sqlite3, this is apart of the bundled libsqlite3, I don't really wanna play around with our bundled libs and make it a bigger issue for those who maintain and upgrade them.
 - ext/readline, the call to GetProcAddress() here does not do any system calls, so it is left as is.
 - win32/ioutil.c uses GetProcAddress(), but the function it attempts to load (PathCchCanonicalizeEx()) is only available from Windows 8 and greater (Pathcch.lib linkage).
 - win32/time.c uses GetSystemTimePreciseAsFileTime() which is available from Windows 8 and greater to get the current system date and time which the highest possible precision and falls back to GetSystemTimeAsFileTime() (available as of Windows 2000), again Kernel32.lib, the GetSystemTimePreciseAsFileTime() is left in a GetProcAddress().
2016-08-11 02:09:50 +02:00
Anatol Belski
fad3f936ac fix ts build 2016-08-03 12:16:42 +02:00
Christoph M. Becker
3d0002ed36 Merge branch 'PHP-7.0' into PHP-7.1 2016-08-02 18:56:35 +02:00
Christoph M. Becker
3a8c027ec3 Merge branch 'PHP-5.6' into PHP-7.0 2016-08-02 18:49:59 +02:00
Christoph M. Becker
f5622f5c87 Fix #72709: imagesetstyle() causes OOB read for empty $styles
Calling imagesetstyle() with an empty $styles array caused gdImageSetStyle()
to be called with `noOfPixels==0`, what could have lead to OOB reads.
Actually, this issue will be fixed in libgd, but to avoid issues when older
libgd is in use, we simply disallow passing an empty $styles array to
imagesetstyle(), what wouldn't serve a useful purpose anyway.
2016-08-02 18:43:37 +02:00
Christoph M. Becker
d795a6bf97 Implement #52857: Access to gdImageSetClip() and gdImageGetClip()
We add the necessary PHP bindings for both functions which are available
as of GD_2_0_12 (released 2006-04-05). The API of imagegetclip() is modelled
according to imageftbbox().
2016-07-23 16:14:36 +02:00
Pierre Joye
439e2ae516 Merge branch 'PHP-7.0'
* PHP-7.0:
  #72482, Ilegal write/read access caused by gdImageAALine overflow
  fix #72494, improve input color check and prevent issues when old gd are used, done before gd call
  improve fix #72558, free contribRow as well
2016-07-19 19:35:40 +07:00
Pierre Joye
2767d1953f merge conflict 2016-07-19 18:55:09 +07:00
Pierre Joye
1d69028d2f fix #72494, improve input color check and prevent issues when old gd are used, done before gd call 2016-07-19 18:23:51 +07:00
Christoph M. Becker
2f81707425 Merge branch 'PHP-7.0' 2016-07-19 00:55:13 +02:00
Christoph M. Becker
d565d4bc1c Merge branch 'PHP-5.6' into PHP-7.0
# Resolved conflicts:
#	ext/gd/gd.c
2016-07-19 00:48:10 +02:00
Christoph M. Becker
3c3980caa1 Merge branch 'pull-request/1991' into PHP-5.6 2016-07-19 00:42:49 +02:00
Christoph M. Becker
6cb75fb1e8 Fix #70315: 500 Server Error but page is fully rendered
That happens because the external libgd uses other error codes than PHP
(and the bundled libgd), but the libgd error codes are simply forwarded
to php_verror(). We fix that by properly mapping libgd errors to PHP errors.
2016-07-19 00:18:07 +02:00
Christoph M. Becker
5aaffb7908 Merge branch 'PHP-7.0' 2016-07-14 17:31:03 +02:00
Christoph M. Becker
5829458215 Merge branch 'PHP-5.6' into PHP-7.0 2016-07-14 17:25:13 +02:00
Christoph M. Becker
8bb3bd04a9 Fix bug #72596: imagetypes function won't advertise WEBP support
We add the constant IMG_WEBP and make sure that WebP support is properly
reported by imagetypes().
2016-07-14 17:17:59 +02:00