summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec
AgeCommit message (Collapse)Author
2018-04-03Re-arrange so inline vectors come last in structs.Tom Sepez
This might make the memory tools more effective in finding OOBs. Change-Id: Id093bb0a88c37954c80d612ac00b5a168e75bdbf Reviewed-on: https://pdfium-review.googlesource.com/29550 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-03-21Rename foo_{wid,hei} to foo_{width,height}.Lei Zhang
Change-Id: I94412dd183535c18f4421b465f64870b44ad230d Reviewed-on: https://pdfium-review.googlesource.com/28971 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-03-21Rename "des_foo" to "dest_foo".Lei Zhang
Destination variables usually have "dest" or "dst" as the prefix. Change-Id: If5bb01a5eafe1e4b42d1a6d653abb1b444b1b2fa Reviewed-on: https://pdfium-review.googlesource.com/28970 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-03-21Add helpers to work with FXDIB_Format.Lei Zhang
Helper functions make getting the bpp and component count more readable. Change-Id: Ie0f97d52136d11ef5251f6e22748e87aea289ae1 Reviewed-on: https://pdfium-review.googlesource.com/28572 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-03-06Rename core/fxcrt IFX files to IfaceDan Sinclair
This CL renames the 3 IFX files in core/fxcrt to Iface instead. Change-Id: I7cee6836650b71bc5c5729a8147fda62f0910fe3 Reviewed-on: https://pdfium-review.googlesource.com/27970 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-16Fix fallthroughs in XFA code.chromium/3350Henrique Nakashima
Change-Id: I1fd4bf85cd709de1c14ed2895d045018f79bc61f Reviewed-on: https://pdfium-review.googlesource.com/26950 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-02-13Change return value of GetAvailInputRyan Harrison
This changes the return value from uint32_t to FX_FILESIZE, which is the type the methods is uses return. The existing code does an unguarded static cast, so something like -1 could cause a very large value being returned. This change has a cascading impact up to the top of the progressive codec, which now has to handle negative values gracefully. Change-Id: I813fb71e932dd5da014dbaed0dbf3bb28f8d4e9f Reviewed-on: https://pdfium-review.googlesource.com/26450 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-02-07Remove some deprecated RenderPage method usage.Lei Zhang
Do some additional checks in test cases where pages were rendered but the resulting bitmap was immediately destroyed. Change-Id: I2f4678140cdc672ab4ced70f748135464447ff59 Reviewed-on: https://pdfium-review.googlesource.com/25510 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-02-07Clean up RenderPage methods in EmbedderTest.Lei Zhang
Add replacement methods that make themselves clear as to what they are rendering, and return unique_ptrs to help prevent leakage. Mark existing methods deprecated. Change-Id: I9055407e614dfbe765428fb32a7da64df3418d1d Reviewed-on: https://pdfium-review.googlesource.com/25470 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-02-06Extract classes in fx_bmp.h into their own filesRyan Harrison
BUG=chromium:808336 Change-Id: I3201805a374b5403149eca701714ef4369a2e337 Reviewed-on: https://pdfium-review.googlesource.com/25630 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-02-06Convert BMP class name style to match other codecsRyan Harrison
BMPDecompressor -> CFX_BmpDecompressor CBmpContext -> CFX_BmpContext BUG=chromium:808336 Change-Id: If8ef5294171e3619ae1d7c5175ddf23b7673ec78 Reviewed-on: https://pdfium-review.googlesource.com/25611 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-02-06Move core/fxcodec/lbmp/ -> core/fxcodec/bmp/Ryan Harrison
BUG=chromium:808336 Change-Id: Id721787dd77d1bcac6daf6e3c149f79e8d1d9fe4 Reviewed-on: https://pdfium-review.googlesource.com/25610 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-02-06Changing the member naming style in BMPDecompressorRyan Harrison
Currently there is no indication in the name of it being a member variable and the capitalization is inconsistent. This CL brings them all into line with Chromium style. BUG=chromium:808336 Change-Id: Iaed0272b69350f316371a67eb513934a0169f451 Reviewed-on: https://pdfium-review.googlesource.com/25430 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-02-05Limit dest buffer to 1GB in FlateOrLZWDecode.Henrique Nakashima
Bug: chromium:802094 Change-Id: I99d2d75cd431afe1cdb966e1431143ab43dd9a73 Reviewed-on: https://pdfium-review.googlesource.com/24730 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-01-30Check if opj_image_data_alloc returned null.Henrique Nakashima
Bug: chromium:797726 Change-Id: Ib13d5a4a78de462f1257f1103728f2a4111cb916 Reviewed-on: https://pdfium-review.googlesource.com/24510 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-01-29Remove duplicate assignments in sycc420_to_rgb().Lei Zhang
BUG=chromium:805881 Change-Id: I3b4914325833c859285a4af1f6e326872cbf1b18 Reviewed-on: https://pdfium-review.googlesource.com/24091 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-01-26Fix potential memory leak in CCodec_JpegModule::Start().Lei Zhang
BUG=chromium:805881 Change-Id: I91266367296218998d011dd5f62e0b4c6df291a3 Reviewed-on: https://pdfium-review.googlesource.com/24070 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-01-19Remove code added in by a bad rebase or mergechromium/3328chromium/3327chromium/3326Ryan Harrison
The guard being removed was moved lower down in the code, but it appears the original creeped back in while I was rebasing at some point. This is causing clusterfuzz failures. BUG=chromium:803732,chromium:803735 Change-Id: I5bcc6046e64d6060a674f390e243dd8eda9d1d17 Reviewed-on: https://pdfium-review.googlesource.com/23250 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-01-18Move format specific elements out of ContinueDecodeRyan Harrison
Refactoring the big image format switch in ContinueDecode to call separate methods for each image format, instead of having one giant switch block. This should have no functional changes. BUG=pdfium:976 Change-Id: Ide4892526ee823023c233f0e43b1c98ac8bd1477 Reviewed-on: https://pdfium-review.googlesource.com/23134 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-01-17Move format specific elements out of StartDecodechromium/3324Ryan Harrison
Refactoring the big image format switch in StartDecode to call separate methods for each image format, instead of having one giant switch block. This should have no functional changes. BUG=pdfium:976 Change-Id: I4e609ecaec0c5d0e173957c0795555b37c38f9a2 Reviewed-on: https://pdfium-review.googlesource.com/23131 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-01-17Move format specific elements out of DetectImageTypeRyan Harrison
Refactoring the big image format switch in DetectImageType to call separate methods for each image format, instead of having one giant switch block. This should have no functional changes. BUG=pdfium:976 Change-Id: I52cc83879da20b33d471420016f6b1eb53993f0b Reviewed-on: https://pdfium-review.googlesource.com/23130 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-01-17Remove param checking from StartScanLineRyan Harrison
By catching this early we are now actually returning the wrong value. The bad value should be passed into the jpeg library code, which will cause a fatal error and jump out to the common error handling code for this method. BUG=pdfium:986 Change-Id: Ib3d32939aa38aece887c014c3a477407ee178193 Reviewed-on: https://pdfium-review.googlesource.com/23119 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-01-17Move remaining jpeg error handling up a levelRyan Harrison
This moves the setjmps needed for handling fatal errors in the jpeg library up a level to be in line with how other instances of this are being modified. This additionally reduces the number of times that setjmp needs to be called and documents why it is occurring. This covers the Start and ReadScanLine methods. It also adds in setting the error member, which had been missed in previous CLs. BUG=pdfium:986 Change-Id: I7db87288ffe0ee8b29899d97035c30ad812da76a Reviewed-on: https://pdfium-review.googlesource.com/23117 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-01-17Move jpeg header read error handling up a levelRyan Harrison
This move the setjmp needed for handling fatal errors in the jpeg library up a level to be in line with how other instances of this are being modified. This additionally reduces the number of times that setjmp needs to be called and documents why it is occuring. BUG=pdfium:986 Change-Id: Ia57821e1ce65aae811618effb3f2fa6256e1ab8c Reviewed-on: https://pdfium-review.googlesource.com/23115 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-01-17Correctly handle errors when starting jpeg codecRyan Harrison
The current implementation treats both returning false and longjmp'ing out of jpeg_start_decompress as indicating that the decompression has paused and needs more data. This is incorrect, in reality only the false return value indicates this. The longjmp path indicates a fatal error in the processing of the jpeg. The default implementation actually calls exit() in this case, and the documentation explicitly calls out that in this case recovery isn't possible and the decode process will have to start from scratch. This resolves a situation where the progressive decoder would get a malformed jpeg and keep on grabbing blocks from it and try to start decoding it. This would eventually fail when it ran out of data to read, but would cause a large memory leak and a crash on the MSAN fuzzers. BUG=pdfium:986,chromium:798665 Change-Id: Ifd2ed7a2dc46fa20bab34e9c461a8d4c4718c4d7 Reviewed-on: https://pdfium-review.googlesource.com/23072 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-12-01Get rid of else after break/continue/return.chromium/3284chromium/3283Lei Zhang
Change-Id: I3efc57cd7325d16e3ca8ebdeeaec06012b2c56e3 Reviewed-on: https://pdfium-review.googlesource.com/20110 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-11-29Allow building pdfium against the system version of libpng.Andrew Weintraub
Bug: Change-Id: I0c930ca30637f58af3b60ed8f1383bd9234a1723 Reviewed-on: https://pdfium-review.googlesource.com/19850 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-11-27Convert CFX_GifContext::GetFrameNum to size_tDan Sinclair
This CL removes the CollectionSize and updates call locations as needed. Bug: pdfium:774 Change-Id: I813c500b3a17a194407ceb1304252b9b16fe1779 Reviewed-on: https://pdfium-review.googlesource.com/19590 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2017-11-21Avoid passing pointers by reference in core.Lei Zhang
This gets rid of most core/ non-const ref passing, either by passing by pointer-to-pointer instead, or by returning std::pair. Change-Id: Id7bdc355a1a725a05f9fa2f1e982ca8c975beef1 Reviewed-on: https://pdfium-review.googlesource.com/19030 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-11-03Remove flags param from FXMEM_DefaultAlloc() and friends.Lei Zhang
Change-Id: I24404be0065156a1cfdec31bafdf72c27fa70142 Reviewed-on: https://pdfium-review.googlesource.com/17792 Reviewed-by: Chris Palmer <palmer@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-11-03Check for NULL pointer in _TIFFfree().chromium/3258Lei Zhang
PartitionAlloc does not handle free(NULL), so _TIFFfree() needs to do the check, just like png_free_default() and _cmsFree() for other third party code. BUG=chromium:780709 Change-Id: I4e2ff0ba642c66e4a73e151c9ab42ebb42d34a5b Reviewed-on: https://pdfium-review.googlesource.com/17791 Reviewed-by: Chris Palmer <palmer@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-09-28Simplify some OS checks to PLATFORM checksDan Sinclair
This CL simplifies the OS == WIN{32|64} checks to be PLATFORM == WINDOWS checks. Change-Id: I1493d316dd457b0228e4ef39db4cf1d2b8abf97d Reviewed-on: https://pdfium-review.googlesource.com/14870 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-27Remove error strings from BMP decoding pathRyan Harrison
These are error strings are set but never used for anything. BUG=pdfium:907 Change-Id: I08d9547009116f7386d15b4a965b9a99c7bf1997 Reviewed-on: https://pdfium-review.googlesource.com/15010 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-27Cleaning up naming of GIF files/classes/variablesRyan Harrison
Moved everything from core/fxcodec/lgif to core/fxcodec/gif Converted CGifContext -> CFX_GifContext Removed _ptr suffixes from CXF_GifContext Movef fx_gif.* -> cfx_gif.* Renamed structs in cfx_gif.h Renamed members of CFX_GifImage Renamed members of CFX_GifContext Renamed CFX_LZWDecoder -> CFX_LZWDecompressor BUG=pdfium:903 Change-Id: I537e905e935da26832e6bbdc03e0373ed5500bcb Reviewed-on: https://pdfium-review.googlesource.com/14990 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-27Remove FXSYS_strlen and FXSYS_wcslenchromium/3226Ryan Harrison
With the conversion of internal string sizes to size_t, these wrappers are no longer needed. Replacing them with strlen and wcslen respectively. BUG=pdfium:828 Change-Id: Ia087ca2ddaf688a57ec9bd9ddfb8533cbe41510d Reviewed-on: https://pdfium-review.googlesource.com/14890 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-27Remove FX_STRSIZE and replace with size_tRyan Harrison
BUG=pdfium:828 Change-Id: I5c40237433ebabaeabdb43aec9cdf783e41dfe16 Reviewed-on: https://pdfium-review.googlesource.com/13230 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-27Remove unreachable code in fx_codec_iccNicolás Peña
This CL removes unreachable code and also removes the flag Icc_Format_DEFAULT which becomes unused. Bug: chromium:346399 Change-Id: I1cdd0f70ffec2abcd20ddf5b181273971b92ecaa Reviewed-on: https://pdfium-review.googlesource.com/14850 Commit-Queue: Nico Weber <thakis@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org>
2017-09-27Cleanup FX macrosDan Sinclair
This CL renames the FX_OS defines to have _OS_ in their names and drops the _DESKTOP suffix. The FXM defines have been changed to just FX. Change-Id: Iab172fba541713b5f6d14fb8098baf68e3364c74 Reviewed-on: https://pdfium-review.googlesource.com/14833 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-26Remove _FX_IOS_chromium/3225Dan Sinclair
The _FX_IOS_ define is never defined, so it isn't useful to check _FX_OS_ against. Remove. Change-Id: I90b50a1a0dc165073ed223cbfe861b9a227818dd Reviewed-on: https://pdfium-review.googlesource.com/14831 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-09-26Confirm that a global palette has data before attempting to use itRyan Harrison
Previous implementation assumed that if the local colour palette was not specified and the global palette had its size specified, then use the global. If the global palette is disable, it will not have data, but it may have a size. Technically the size is giberish in this case, but the value is allowed to be non-zero, so isn't a sufficient check. BUG=chromium:768089 Change-Id: Iaec15fcd65f3983056df7d56d29118a516334cd9 Reviewed-on: https://pdfium-review.googlesource.com/14819 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-22Move C-style functions into CGifContextRyan Harrison
There are a number of functions in fx_gix.h/.cpp that take in a pointer to a CGifContext as their first parameter. Moving these to be methods in that class. BUG=pdfium:902 Change-Id: I8c583ab9e42dda4241aa8a6f865408a94fa6d273 Reviewed-on: https://pdfium-review.googlesource.com/14670 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-09-22Fix crash when rendering invalid GIFRyan Harrison
The core fix in this CL is a change to how LWZ decompression works, so that when the min code table size and the color palette size are different, color codes after the end of the defined color palette are considered errors. This CL also introduces a bunch of tweaks to the call return path, since there were multiple locations where the GIF decode failing status was being dropped on the floor, so the end widget would have a bitmap with the default colour in it, instead of nothing. BUG=chromium:616671 Change-Id: Id6f40d552dc24650c91e9903f710ff2fa63bc774 Reviewed-on: https://pdfium-review.googlesource.com/14630 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-21Move CFX_UnownedPtr to UnownedPtrDan Sinclair
This CL moves CFX_UnownedPtr to UnownedPtr and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I6d1fa463f365e5cb3aafa8c8a7a5f7eff62ed8e0 Reviewed-on: https://pdfium-review.googlesource.com/14620 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-21Rename CFX_RetainPtr to RetainPtrDan Sinclair
This CL renames CFX_RetainPtr to RetainPtr and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I8798a9f79cb0840d3f037e8d04937cedd742914e Reviewed-on: https://pdfium-review.googlesource.com/14616 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-09-20Isolate lcms2 usage to a few files.Lei Zhang
Then set up the right dependencies for them. BUG=chromium:765914 Change-Id: I036cd888c741927d5efe0d020c6676f169e7cbb1 Reviewed-on: https://pdfium-review.googlesource.com/14410 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-20Forward declare codec modules in fx_codec.h.Lei Zhang
Change-Id: I020b862619f3f93f71dbb027b9e799d78744f686 Reviewed-on: https://pdfium-review.googlesource.com/14391 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-20Move CCodec_ScanlineDecoder to its own file.Lei Zhang
Change-Id: Icacf877e2b66ca7d49637dcf9eaec0f99bcdd8bb Reviewed-on: https://pdfium-review.googlesource.com/14390 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-09-19Remove unneeded core/fxcodec/fx_codec.h includes.chromium/3220Lei Zhang
Change-Id: I703321108712e8c4a11a8343ecf8b1a8804c1d1a Reviewed-on: https://pdfium-review.googlesource.com/14352 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-09-18Convert string class namesRyan Harrison
Automated using git grep & sed. Replace StringC classes with StringView classes. Remove the CFX_ prefix and put string classes in fxcrt namespace. Change AsStringC() to AsStringView(). Rename tests from TEST(fxcrt, *String*Foo) to TEST(*String*, Foo). Couple of tests needed to have their names regularlized. BUG=pdfium:894 Change-Id: I7ca038685c8d803795f3ed02545124f7a224c83d Reviewed-on: https://pdfium-review.googlesource.com/14151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-09-14Revert moving JPX library decode from Init to DecodeRyan Harrison
Due to some of the size parameters for allocating space in Decode() depending on the values produced by opj_decode(), this change was causing misallocation of space, which in turn was causing illegal reads/writes. The issue with excessive memory usage that the original CL was trying to change is less significant than the above mentioned problems, so reverting this fix and looking for another solution to the problem. This will re-open bugs https://crbug.com/754423 and https://crbug.com/761005. BUG=chromium:764177,chromium:754423,chromium:761005 Change-Id: I1cafac8a8117ec1e3bc32b31196bdec719d46477 Reviewed-on: https://pdfium-review.googlesource.com/13950 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>