Commit Graph
93 Commits
Author SHA1 Message Date
Albert Astals Cid 343954ca98 psd: Fix crash on broken files
Instead of resizing the bytearray to the potential size and then reading
into it, ask the device to read into a bytearray, this way instead of a
crash because we're trying to resize to a too big number we get a nice
  maxSize argument exceeds QByteArray size limit
warning

oss-fuzz/46664
2022-04-13 23:07:22 +02:00
Albert Astals Cid c8a0806aab psd: Don't crash with broken images
Found by oss-fuzz but still with an unfiled bug number
2022-04-10 12:19:52 +02:00
Albert Astals Cid bb475dedd1 psd: Header depth has to be 8 for CM_INDEXED color_mode
As suggested by Mirco Miranda
2022-04-07 23:50:15 +02:00
Albert Astals Cid 9e28aae868 psd: Protect against broken images
If you have an image that says it's Mono but has 16 as header.depth we
end up doing invalid memory accesses

oss-fuzz/46437
2022-04-07 21:46:08 +00:00
Albert Astals Cid 5c47a97b79 psd: Don't abort on broken images
oss-fuzz/46418
2022-04-06 22:58:31 +00:00
Albert Astals Cid 384f78a13c psd: Don't assert on broken files
oss-fuzz/46407
2022-04-06 00:16:38 +02:00
Albert Astals Cid 4afafee6c1 Add write tests for heif/avif/jxl
Unfortunately none of them pass since it seems they can't load a png,
save it to their format with loseless quality and read it back and get
exactly the same contents than the png
2022-02-18 00:05:01 +01:00
Albert Astals Cid 1d2b51ddf1 Fix build with clang12 + libc++ 2021-08-30 20:29:23 +02:00
Albert Astals Cid 7642633551 SGIImage::writeImage: Properly fail if the image is too big 2021-08-19 17:29:44 +02:00
Albert Astals Cid 9f2c5061c8 exr: Port to std::log/pow
The Imath functions are marked as deprecated and they just call the
std::log/pow anyway
2021-08-18 21:51:53 +00:00
Albert Astals Cid a8f92e5525 PCXHandler::write: Properly fail if the image is too big 2021-08-12 16:43:52 +02:00
Albert Astals Cid fbeef559b7 exr: Repair compability with openexr2
BUGS: 440084
2021-07-21 00:04:45 +02:00
Albert Astals Cid 5aa03c12ad exr: Override the actual function signature
For gcc there's a typedef that makes it work, but seems clang in macos is
not so lucky

BUGS: 439767
2021-07-12 20:15:12 +02:00
Albert Astals Cid ff53d3d7e9 xcf: Make sure offsets are not negative
It's not a huge problem since QIODevice::seek() is a noop on negative values but it's
just better to bail out as soon as possible when we realize the file is
broken
2021-05-05 17:23:59 +02:00
Albert Astals CidandDavid Faure 297ed9a2fe xcf: Fix Stack-buffer-overflow WRITE on broken files
oss-fuzz/33742
2021-05-02 09:50:50 +00:00
Albert Astals Cid 3cb4021afc test: imageconverter: add a way to list mimes instead of formats 2021-04-05 09:44:03 +00:00
Albert Astals Cid 2755f74fbb ani: convert +1 to -1 so we don't do a potential integer overflow
oss-fuzz/32601

runtime error: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
2021-04-03 22:46:33 +00:00
Albert Astals Cid 8ad43638ad Fix crash with malformed files
oss-fuzz/29284
2021-01-08 14:02:45 +00:00
Albert Astals Cid c72c9f577b ani: Make sure riffSizeData is of the correct size before doing the quint32_le cast dance
oss-fuzz/29290
2021-01-05 21:52:24 +01:00
Albert Astals Cid 82d5e0f8a4 Remove ifdefs, we require Qt 5.14 now 2020-12-18 19:34:07 +01:00
Albert Astals Cid bbf945137a GIT_SILENT Upgrade Qt5 version requirement to 5.14.0. 2020-12-18 19:02:54 +01:00
Albert Astals Cid 02cbf3889f GIT_SILENT Upgrade Qt5 version requirement to 5.13.0. 2020-11-27 00:45:24 +01:00
Albert Astals Cid d36c191351 tests: Remove qimage_format_enum_names and just use QMetaEnum 2020-11-09 19:15:36 +00:00
Albert Astals Cid ce56b97ee7 GIT_SILENT Upgrade Qt5 version requirement to 5.12.0. 2019-12-21 12:34:54 +01:00
Albert Astals Cid f03739f222 pic: Fix Invalid-enum-value undefined behaviour
Summary:
Instead of directly casting the quint8 to PicChannelEncoding we just store the quint8
and compare it to the possible PicChannelEncoding values when needed

oss-fuzz/19344

Reviewers: dfaure

Reviewed By: dfaure

Subscribers: dfaure, security-team, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D25937
2019-12-14 21:05:02 +01:00
Albert Astals Cid bf5502403e Add files for testing bug411327 2019-09-20 23:18:17 +02:00
Albert Astals Cid 5c4c05257c xcf: Fix regression when reading files with "unsupported" properties
Summary:
The fact that we don't know the property is most of the times not fatal,
so what we have to do is just "skip" the property and hope for the best

BUGS: 411327

Reviewers: cfeck, apol, vkrause

Reviewed By: vkrause

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D24114
2019-09-20 22:41:26 +02:00
Albert Astals Cid 7afaacb093 xcf: Properly read image resolution
Summary:
QDataStream reads 64 bits when reading into a float unless you tell it to use SinglePrecision,
since floats in xcf are 32 bit, do that

Reviewers: cfeck, apol, vkrause

Reviewed By: vkrause

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D24113
2019-09-20 22:41:03 +02:00
Albert Astals Cid 4bf2894bde Fix uninitialized memory read
Summary:
Make sure whole of pixel_size in pixel has data either because it was
read or because we set it to 0

oss-fuzz/14565

Reviewers: dfaure, apol, vkrause

Reviewed By: vkrause

Subscribers: kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D23739
2019-09-05 20:05:35 +02:00
Albert Astals Cid 75ef81a109 QImage::byteCount -> QImage::sizeInByes 2019-07-04 22:26:53 +02:00
Albert Astals Cid bff22e2a76 GIT_SILENT Upgrade Qt5 version requirement to 5.11.0. 2019-07-04 19:23:58 +02:00
Albert Astals Cid 1a9b5d6cb6 tga: don't try to read more than max_palette_size into palette 2019-05-01 01:51:42 +02:00
Albert Astals Cid 96b1d7e7bc tga: memset dst if read fails 2019-05-01 01:51:39 +02:00
Albert Astals Cid bcce48012e tga: memset the whole palette array, not only the palette_size 2019-05-01 01:44:47 +02:00
Albert Astals Cid 0db5c89c5f Initialize the unread bits of _starttab
oss-fuzz #14446
2019-04-25 23:08:17 +02:00
Albert Astals Cid 6fea48c4ee xcf: Fix uninitialized memory use on broken documents
oss-fuzz #14312
2019-04-17 20:09:49 +02:00
Albert Astals Cid 645daec1ef ras: Don't overread input on malformed files 2019-04-17 20:03:52 +02:00
Albert Astals Cid aaa285a3b9 xcf: layer is const in copy and merge, mark it as such 2019-04-17 17:37:28 +02:00
Albert Astals Cid 35e64c44d8 No & is a bit faster here 2019-04-17 17:37:28 +02:00
Albert Astals Cid 26b796f67d const & is a bit faster here 2019-04-17 17:37:28 +02:00
Albert Astals Cid 4692a34a1c QStringLiteral is a bit faster here 2019-04-17 17:37:28 +02:00
Albert Astals Cid 83d1ca90d9 Fix compilation
Summary:
Seems only gcc can do a constexpr with strlen.

This fixes the build with clang, hopefully to with MSVC?

Reviewers: svuorela

Reviewed By: svuorela

Subscribers: svuorela, apol, pino, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D20149
2019-03-31 22:18:16 +02:00
Albert Astals Cid fd4fb6f596 ora:kra: qstrcmp -> memcmp
i..e don't check strings but memory

Makes oss-fuzz happier.

Reviewers: svuorela

Reviewed By: svuorela

Subscribers: apol, pino, security-team, rempt, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D20143
2019-03-31 21:32:07 +02:00
Albert Astals Cid a24ece396a autotests: Also exercise canRead 2019-03-31 20:58:26 +02:00
Albert Astals Cid 9fc6967f4f Fix RGBHandler::canRead
Summary:
As one can see in SGIImage::readImage the accepted images are

    _stream >> u16;
    if (u16 != 0x01da) {
        return false;
    }

    _stream >> _rle;
    if (_rle > 1) {
        return false;
    }

so not only \x01\xda\x01 but also \x01\xda\x00

Reviewers: svuorela

Reviewed By: svuorela

Subscribers: svuorela, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D20145
2019-03-31 19:44:21 +02:00
Albert Astals Cid bd704045e6 xcf: Don't crash with files with unsupported layer modes 2019-03-31 01:35:33 +01:00
Albert Astals Cid 20100a1e0e ras: fix crash on broken files
Replace QVector::operator[] with QVector::value() since we can't know for
sure the values will be on range so use value() that gives us a 0 if the
index is not on range

oss-fuzz/13462
2019-03-01 23:33:35 +01:00
Albert Astals Cid 156bac5e54 ras: protect the palette QVector too
oss-fuzz/13068
2019-02-13 23:50:36 +01:00
Albert Astals Cid d79c11d280 ras: tweak max file check
better to do - 32 than + 32 otherwise we may overflow

oss-fuzz/13017
2019-02-11 22:57:33 +01:00
Albert Astals Cid aeec934839 xcf: Fix uninitialized memory use on broken documents
oss-fuzz/12871
2019-02-08 23:27:03 +01:00
Albert Astals Cid 0c4f2f8e62 add const, helps understand the function better 2019-02-08 23:07:56 +01:00
Albert Astals Cid 4a8da73f0e ras: tweak max size that "fits" in a QVector
oss-fuzz/12951
2019-02-07 22:14:22 +01:00
Albert Astals Cid 039d7d8fbe ras: don't assert because we try to allicate a huge vector
oss-fuzz/12915
2019-02-06 22:06:58 +01:00
Albert Astals Cid b072484dbb ras: Protect against divide by zero
oss-fuzz/12905
2019-02-05 19:51:24 +01:00
Albert Astals Cid bad90cea4b xcf: Don't divide by 0
oss-fuzz/12815
2019-02-03 14:06:33 +01:00
Albert Astals Cid a51cbd865f tga: fail gracefully if readRawData errors
oss-fuzz/12818
2019-02-03 13:49:11 +01:00
Albert Astals Cid 1a31500e55 ras: fail gracefully on height*width*bpp > length
oss-fuzz/12822
2019-02-03 13:38:44 +01:00
Albert Astals Cid 8d0b625538 xcf: Fix fix for opacity being out of bounds
If max opacity is 255 we want the min between opacity and 255 and not the max
2019-02-01 11:30:28 +01:00
Albert Astals Cid 8e48d67568 Uncomment the qdebug includes
i've wasted enough time uncommenting and commenting them again
2019-01-31 01:37:09 +01:00
Albert Astals Cid 8b8330b0fe tga: Fix Use-of-uninitialized-value on broken files
oss-fuzz/12776
2019-01-31 01:35:39 +01:00
Albert Astals Cid e7f3c0be44 max opacity is 255
Fixes oss-fuzz/12782
2019-01-31 01:25:38 +01:00
Albert Astals Cid c3152506e2 xcf: Fix assert in files with two PROP_COLORMAP
It's most probably a broken file but better if we don't assert ^_^

oss-fuzz/12780
2019-01-31 01:19:52 +01:00
Albert Astals Cid de7a9a8457 ras: Fix assert because of ColorMapLength being too big
oss-fuzz/12785
2019-01-31 01:03:17 +01:00
Albert Astals Cid c2d2a9be66 pcx: Fix crash on fuzzed file
oss-fuzz/12784
2019-01-31 00:56:25 +01:00
Albert Astals Cid 4ee92527c4 xcf: Implement robustness for when PROP_APPLY_MASK is not on the file
fixes oss-fuzz/12754
2019-01-29 22:34:04 +01:00
Albert Astals Cid 1bad780baa xcf: loadHierarchy: Obey the layer.type and not the bpp
Otherwise we end up doing uninitialized memory reads on broken/fuzzed
files

oss-fuzz/12761
2019-01-29 20:36:15 +01:00
Albert Astals Cid 18e17d3a7a tga: Don't support more than 8 alpha bits
Fixes undefined left shift with negative values

oss-fuzz/12764
2019-01-29 12:39:52 +01:00
Albert Astals Cid e34f53d6ae ras: Return false if allocating the image failed
Probably because it's too huge
2019-01-29 12:32:23 +01:00
Albert Astals Cid 6dcea7fd01 rgb: Fix integer overflow in fuzzed file
oss-fuzz/12763
2019-01-29 11:19:58 +01:00
Albert Astals Cid 4751e897ce rgb: Fix Heap-buffer-overflow in fuzzed file
oss-fuzz/12757
2019-01-29 10:54:25 +01:00
Albert Astals Cid ac725cca68 psd: Fix crash on fuzzed file
oss-fuzz/12752
2019-01-29 10:53:30 +01:00
Albert Astals Cid f61d64e0e5 xcf: Initialize x/y_offset
https://gitlab.gnome.org/GNOME/gimp/raw/master/devel-docs/xcf.txt
  When reading old XCF files that lack this property, assume (0,0).
2019-01-28 21:51:10 +01:00
Albert Astals Cid e45b65e814 rgb: Fix crash in fuzzed image
An image without color channels makes no sense
2019-01-28 21:48:26 +01:00
Albert Astals Cid 7e86e62e86 pcx: Fix crash on fuzzed image 2019-01-28 21:40:42 +01:00
Albert Astals Cid 03c3c07004 Fix tests on jenkins
Qt also has a tga image plugin so unless we make sure ours is used first
tests are not testing what they should

On a side note their plugin fails our tests so someone with enough time
should report the failures to them
2019-01-28 21:27:22 +01:00
Albert Astals Cid 0e21713267 rgb: fix crash in fuzzed file 2019-01-28 21:10:18 +01:00
Albert Astals Cid 188271a5d0 xcf: initialize layer mode
https://gitlab.gnome.org/GNOME/gimp/raw/master/devel-docs/xcf.txt
  When reading old XCF files that lack this property, assume mode==0.
2019-01-28 21:05:29 +01:00
Albert Astals Cid 311296dd19 xcf: initialize layer opacity
https://gitlab.gnome.org/GNOME/gimp/raw/master/devel-docs/xcf.txt
  When reading old XCF files that lack this property, full opacity
  should be assumed.
2019-01-28 20:31:18 +01:00
Albert Astals Cid d6ae11a691 xcf: set buffer to 0 if read less data that expected
Fixes MemorySanitizer: use-of-uninitialized-value on fuzzed file
2019-01-28 20:09:21 +01:00
Albert Astals Cid 3923c9b855 bzero -> memset
Seems bzero is less portable
2019-01-28 19:18:01 +01:00
Albert Astals Cid 52a5959c08 pic: resize header id back if didn't read 4 bytes as expected 2019-01-28 01:56:12 +01:00
Albert Astals Cid 309cddbe83 xcf: bzero buffer if read less data than expected 2019-01-28 01:30:17 +01:00
Albert Astals Cid 47f46d4463 xcf: Only call setDotsPerMeterX/Y if PROP_RESOLUTION is found
https://gitlab.gnome.org/GNOME/gimp/blob/master/devel-docs/xcf.txt says
it's not really that important to be there
2019-01-27 13:14:30 +01:00
Albert Astals Cid bff6142b44 xcf: initialize num_colors 2019-01-27 13:07:37 +01:00
Albert Astals Cid 09abfd8084 xcf: Initialize layer visible property
https://gitlab.gnome.org/GNOME/gimp/blob/master/devel-docs/xcf.txt says
	When reading old XCF files that lack this property, assume that layers are visible
2019-01-27 13:03:51 +01:00
Albert Astals Cid 964624ba40 xcf: Don't cast int to enum that can't hold that int value 2019-01-27 12:50:19 +01:00
Albert Astals Cid 3dee6f7c47 xcf: Do not overflow int on the setDotsPerMeterX/Y call 2019-01-27 12:29:07 +01:00
Albert Astals Cid b8cb5e322c delete copy constructor and assignment operator of some internal classes
they are unused, but if anyone would use them things would go wrong, so protect us from it
2019-01-13 22:30:55 +01:00
Albert Astals Cid 8803ae9cd6 GIT_SILENT Upgrade Qt5 version requirement to 5.10.0. 2019-01-07 00:19:26 +01:00
Albert Astals Cid c3b8030674 GIT_SILENT Upgrade CMake version requirement to 3.5. 2018-12-01 23:56:44 +01:00
Albert Astals Cid 10f201e414 Use gimp to export simple-rgba-gimp-2.8.10.xcf to png again
This fixes the xcf test that was failing, i guess at some point someone
run optipng or something over the expected result and that was causing
the test to fail
2018-11-17 12:22:25 +01:00
Albert Astals Cid 1656913fbd GIT_SILENT Upgrade Qt5 version requirement to 5.9.0. 2018-11-17 11:18:21 +01:00
Albert Astals Cid 55af097749 Don't warn the user/developer about something he can't fix
image formats are loaded via qimage/qimagereader and friends, the user/developer does not choose which ones will be used so giving him a warning about sequential devices not being supported is not going to help anyone, only spam their shell/logs.

REVIEW: 123156
Acked by David Edmundson
2015-03-29 23:21:17 +02:00