1
0
mirror of https://github.com/php/php-src.git synced 2026-03-27 17:52:16 +01:00
Commit Graph

1983 Commits

Author SHA1 Message Date
Christoph M. Becker
eec5d2a25f Properly shut down font cache mutex
Since the font cache mutex in set up in MINIT, we have to shut it down
in MSHUTDOWN.
2019-06-21 16:00:47 +02:00
Christoph M. Becker
81fd113506 Support TGA reading
We add PHP bindings for libgd's features to read TGA files, which are
available as of libgd 2.1.0.

As PHP's bundled libgd doesn't yet include the respective features of the
external libgd, we add these.

Since TGA has no easily recognizable file signature, we don't add TGA
support for imagecreatefromstring() or getimagesize() and friends.
2019-06-20 23:40:51 +02:00
Nikita Popov
4488475a3e imagecolorallocate(): Check that RGB components are in-range
Instead of letting them bleed over into other components.
2019-06-20 10:09:54 +02:00
Nikita Popov
9b3b07cd26 Suppress shift UB in gd_itofx()
There doesn't seem to be a corresponding upstream fix for this.
2019-06-19 17:27:09 +02:00
Nikita Popov
88b603768f imageloadfont: Perform overflow check before calculation
Instead of afterwards...
2019-06-19 15:50:52 +02:00
Nikita Popov
2a9fc31021 Fix buffer underflow in gd_gif_in.c
This has been fixed upstream in
939d49a3a9.
2019-06-19 15:41:45 +02:00
Nikita Popov
ea97fc9c1f Fix shift UB in gd_io.c
This has already been fixed upstream in
24d352576c
and
772d0107a6.
2019-06-19 15:09:00 +02:00
Christoph M. Becker
3c5bb06536 Add BMP support to PHP info 2019-06-13 13:07:01 +02:00
Christoph M. Becker
37d0c7b0e4 Simplify GD null byte injection tests
These tests actually check that no file with a name containing a NUL is
created by the GD image output functions.  This is superfluous, since
it is sufficient to check that the function failed, and that an
appropriate warning has been raised.

We also add missing nullbyte injection tests.
2019-06-12 12:04:01 +02:00
Joe Watkins
2dfa495311 fix flaky gd tests 2019-06-12 07:52:28 +02:00
Nikita Popov
e5411e17c7 Remove unused _setEdgePixel() and getPixelOverflowColorTC() functions 2019-06-11 16:59:12 +02:00
Nikita Popov
5c844c1d36 Fix fabs warning in gd_interpolation.c
Matches upstream code.
2019-06-11 16:57:24 +02:00
Nikita Popov
2290102172 Remove safeboolean use in gd_jpeg.c
This is a backport of
e5502c7a3f/src/gd_jpeg.c.
2019-06-11 16:54:45 +02:00
Nikita Popov
0849a621fd Fix abs(long) warnings in gd.c
I'm fixing this using (int) casts instead of labs() because this is
what upstream GD does.
2019-06-11 16:50:25 +02:00
Nikita Popov
a31f46421d Allow exceptions in __toString()
RFC: https://wiki.php.net/rfc/tostring_exceptions

And convert some object to string conversion related recoverable
fatal errors into Error exceptions.

Improve exception safety of internal code performing string
conversions.
2019-06-05 14:25:07 +02:00
Stanislav Malyshev
892a188fc9 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix function name
2019-05-27 17:21:28 -07:00
Stanislav Malyshev
e63b2ba310 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix function name
2019-05-27 17:21:23 -07:00
Stanislav Malyshev
9bca9ef6cf Fix function name 2019-05-27 17:20:56 -07:00
Stanislav Malyshev
5e3dc08826 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Update NEWS
  Fix bug #78069 - Out-of-bounds read in iconv.c:_php_iconv_mime_decode() due to integer overflow
  Fix #77973: Uninitialized read in gdImageCreateFromXbm
2019-05-27 16:49:31 -07:00
Stanislav Malyshev
c7eb0feed8 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Update NEWS
  Fix bug #78069 - Out-of-bounds read in iconv.c:_php_iconv_mime_decode() due to integer overflow
  Fix #77973: Uninitialized read in gdImageCreateFromXbm
2019-05-27 16:49:25 -07:00
Stanislav Malyshev
e77c8e45ba Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
  Update NEWS
  Fix bug #78069 - Out-of-bounds read in iconv.c:_php_iconv_mime_decode() due to integer overflow
  Fix #77973: Uninitialized read in gdImageCreateFromXbm
2019-05-27 16:49:19 -07:00
Christoph M. Becker
ed6dee9a19 Fix #77973: Uninitialized read in gdImageCreateFromXbm
We have to ensure that `sscanf()` does indeed read a hex value here,
and bail out otherwise.
2019-05-27 16:11:32 -07:00
Peter Kokot
812dbed0e9 [ci skip] Refactor libgd docs
Changes to simplify managing libgd docs a bit:
- Move copyright statement and licensing info to common redistributable
  bins file. All previous notices left intact and updated with the
  upstream info.
- Remove unsynced and difficult to track README file compared to
  upstream README.md file available at https://github.com/libgd/libgd
2019-05-12 23:51:39 +02:00
Peter Kokot
75fb74860d Normalize comments in *nix build system m4 files
Normalization include:
- Use dnl for everything that can be ommitted when configure is built in
  favor of the shell comment character # which is visible in the output.
- Line length normalized to 80 columns
- Dots for most of the one line sentences
- Macro definitions include similar pattern header comments now
2019-05-12 18:43:03 +02:00
Peter Kokot
a68e0767b3 Rename *.jpeg files to *.jpg
These file extensions are not part of these tests and *.jpg is more
common.
2019-05-11 03:22:19 +02:00
Kalle Sommer Nielsen
bcd11a1dfb Implemented the gdScatter filter I wrote almost 10 years ago
This filter is available as of libgd 2.1.0 which is our bare minimum for
external compilation of ext/gd.

The scatter filter works by iterating over all pixels in the image and
shifting them randomly based on two modifier (`plus` and `sub`) values:

dest_x = (int)(x + ((rand() % (plus - sub)) + sub));
dest_y = (int)(y + ((rand() % (plus - sub)) + sub));

Additionally the scatter filter also supports by only shifting pixels where
the current pixel being iterated is one or more colors, allowing the scatter
filter to only effect solid colors in part of an image.

Note, due to the nature of randomness and implementation, pixels who were
shifted ahead of iteration will be shifted once more and therefore the
bottom right of an image may contain a slight scatter effect due to this.
2019-05-10 02:23:40 +03:00
Christoph M. Becker
18a9ae412f Fix #77943: imageantialias($image, false); does not work
Firstly, we must not call `gdImageSetAntiAliased()` (which sets the
color to anti-alias), but rather modify the `gdImage.AA` flag.
Furthermore, we have to actually use the supplied boolean value.

We also make sure that we don't attempt to enable anti-aliasing for
palette images.
2019-04-29 17:23:16 +02:00
Christoph M. Becker
3891e0d13a Add tests for bug77943 2019-04-29 16:29:08 +02:00
Christoph M. Becker
85cf1cb077 Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #77943: imageantialias($image, false); does not work
2019-04-29 16:18:54 +02:00
Christoph M. Becker
3fc1bdc81c Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77943: imageantialias($image, false); does not work
2019-04-29 16:18:27 +02:00
Christoph M. Becker
cd94cf60a2 Fix #77943: imageantialias($image, false); does not work
Firstly, we must not call `gdImageSetAntiAliased()` (which sets the
color to anti-alias), but rather modify the `gdImage.AA` flag.
Furthermore, we have to actually use the supplied boolean value.

We also make sure that we don't attempt to enable anti-aliasing for
palette images.
2019-04-29 16:16:46 +02:00
Rodrigo Prado
ba0f7f7e43 Added test for imagecolorclosesthwb
The function was not tested yet.
See http://gcov.php.net/viewer.php?version=PHP_HEAD&func=tested_functions
2019-04-20 19:31:45 +02:00
Nikita Popov
7207110362 Fix uninit warning in gd.c
This matches the upstream implementation.
2019-04-12 16:03:01 +02:00
Nikita Popov
9d663cba1a Fix libgd warnings 2019-04-11 15:54:09 +02:00
Fabien Villepinte
b6f9ade9f2 Remove unused variables 2019-03-17 23:29:51 +01:00
Fabien Villepinte
26dfce7f36 Replace dirname(__FILE__) by __DIR__ in tests 2019-03-15 22:55:30 +01:00
Peter Kokot
9df6a1e4dd Add AS_HELP_STRING to *nix build configure options
The Autoconf's default AS_HELP_STRING macro can properly format help
strings [1] so watching out if columns are aligned manually is not
anymore.

[1] https://www.gnu.org/software/autoconf/manual/autoconf.html#Pretty-Help-Strings
2019-03-07 20:36:59 +01:00
Christoph M. Becker
f651397b1f Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3:
  Fix #77700: Writing truecolor images as GIF ignores interlace flag
2019-03-06 00:38:12 +01:00
Christoph M. Becker
0d88388912 Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2:
  Fix #77700: Writing truecolor images as GIF ignores interlace flag
2019-03-06 00:37:38 +01:00
Christoph M. Becker
41fb0eaa11 Fix #77700: Writing truecolor images as GIF ignores interlace flag
We  revert the interlace flag related part of commit ff2822a[1], since
contrary to the transparent color, the interlace flag is not retained
by `gdImageCreatePaletteFromTrueColor()`.  This also matches upstream
libgd.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=ff2822a82b740edb8ccf307f080bae188c200fb9>
2019-03-06 00:34:40 +01:00
Nikita Popov
7e3f4a2390 Remove more zpp error/variation tests 2019-03-05 14:09:33 +01:00
Nikita Popov
e27ba75e0f Use separate output files in x2gd tests 2019-03-04 10:48:09 +01:00
Christoph M. Becker
345a75f541 Remove dead code
`_php_image_output()` is only ever called for `PHP_GDIMG_CONVERT_WBM`,
`PHP_GDIMG_TYPE_GD` and `PHP_GDIMG_TYPE_GD2`.  All other image types
solely use the more flexible `_php_image_output_ctx()`.
2019-02-28 13:11:41 +01:00
BlackEagle
a8336fb7b9 gd imageloadfont, verify error while reading header
when reading the header verify we get an error when the header is
invalid.

Signed-off-by: BlackEagle <ike.devolder@gmail.com>
2019-02-19 03:26:00 +01:00
BlackEagle
fee9f3a8f4 gd imageloadfont test while reading header
Cover error when the header of an gd font loading is interrupted by end
of file.

Signed-off-by: BlackEagle <ike.devolder@gmail.com>
2019-02-14 22:29:35 +01:00
Nikita Popov
8bc663f43b Remove zpp variation tests 2019-02-05 09:38:55 +01:00
Peter Kokot
92ac598aab Remove local variables
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.

A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.

This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.

With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.

Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files.  All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
2019-02-03 21:03:00 +01:00
Zeev Suraski
0cf7de1c70 Remove yearly range from copyright notice 2019-01-30 11:03:12 +02:00
Christoph M. Becker
570d4311b6 Use pkg-config to detect and configure for system libgd
Formerly, a single option `--with-gd` was sufficient to enable the
extension, and to determine whether to use the system or the bundled
libgd depending on whether a directory was passed.  Since pkg-config
determines the path automatically, we now offer `--enable-gd` (whether
the extension should be build) and `--with-external-gd` (whether to use
the system libgd).
2019-01-21 14:01:34 +01:00
Christoph M. Becker
089f7c0bc2 Sync with upstream
Even though libgd/libgd#492 is not a relevant bug fix for PHP, since
the binding doesn't use the `gdImage*Ptr()` functions at all, we're
porting the fix to stay in sync here.
2019-01-19 11:30:12 +01:00