summaryrefslogtreecommitdiff
path: root/core
AgeCommit message (Collapse)Author
2017-05-16Introduce CFX_UnownedPtr to detect lifetime inversion issues.Tom Sepez
There are places where an object "child" has a raw pointer back to object "owner" with the understanding that owner will always outlive child. Violating this constraint can lead to use after free, but this requires finding two paths: one that frees the objects in the wrong order, and one that uses the object after the free. The purpose of this patch is to detect the constraint violation even when the second path is not hit. We create a template that is used in place of TYPE*. It's dtor, when a memory tool is present, goes out and probes the first byte of the object to which it points. Used in "child", this allows the memory tool to prove that the "owner" is still alive at the time the child is destroyed, and hence the constraint is never violated. Change-Id: I2a6d696d51dda4a79ee2f00a6752965e058a6417 Reviewed-on: https://pdfium-review.googlesource.com/5475 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-16Simplify ContrastAdjust().chromium/3102Lei Zhang
Add a few constants in the process. Change-Id: Id69b939e4ea6a3de879e0a1f29d1453e95c838db Reviewed-on: https://pdfium-review.googlesource.com/5552 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-15Remove gamma codeDan Sinclair
The gamma value is always 2.2, which means the table entries all point to themselves. Remove the usage of the gamma table. Change-Id: Idbb06015e8acd9f106f4bd1da5ef06563fb26296 Reviewed-on: https://pdfium-review.googlesource.com/5352 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-15Remove unused flags from CPDF_CreatorNicolas Pena
The only user of CPDF_Creator is FPDF_Doc_Save, and it only uses flags 1 or 2 when calling Create. Thus, the other two flags will never be set. Change-Id: Ib2eb0ce5585469c7749f0ab350855f1c6a2bba08 Reviewed-on: https://pdfium-review.googlesource.com/5491 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-15Gif: error out on invalid code sizeschromium/3101Nicolas Pena
From the Gif spec: 'The output codes are of variable length, starting at <code size>+1 bits per code, up to 12 bits per code. This defines a maximum code value of 4095 (0xFFF).' 'Because the LZW compression used for GIF creates a series of variable length codes, of between 3 and 12 bits each' Bug: chromium:722115 Change-Id: Ic9cff99e6012195a6b5173693b029dc710285688 Reviewed-on: https://pdfium-review.googlesource.com/5490 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-15Convert CPSOutput to an IFX_WriteStreamdan sinclair
This Cl updates CPSOutput to inherit from IFX_WriteStream and converts the CFX_PSRenderer to accept an IFX_WriteStream instead of a CPSOutput. Change-Id: Ibde5c7da1c2f6df0a10cb6e9a470e18fbab167b8 Reviewed-on: https://pdfium-review.googlesource.com/5431 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-15Add a WriteString method to IFX_WriteStreamdan sinclair
This Cl allows passing a CFX_ByteStringC to IFX_WriteStream along with the buffer method. This makes it easier to pass C-style strings to the stream. Change-Id: I1051eb3ba17c7fbd42984c14dc60cbce24d72f3f Reviewed-on: https://pdfium-review.googlesource.com/5430 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-12Rename ErrorData and fix potential leakchromium/3100chromium/3099Nicolas Pena
This CL fixes a leak that can be caused by a longjmp in ErrorData. The method is renamed to express the fact that it includes such, and a followup should remove the jmps altogether. Bug: chromium:721488 Change-Id: Iefcc82a77a30ff77b7973b05611440a8d5bf275e Reviewed-on: https://pdfium-review.googlesource.com/5450 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-12Merge FXGIF_Context and CGifDecompressor into CGifContextchromium/3098Nicolas Pena
Change-Id: I60c9cbd83ff9e7a30a5a570a6ad1cf8f52360c07 Reviewed-on: https://pdfium-review.googlesource.com/5410 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-11Use clamp() in a couple more places.Lei Zhang
Change-Id: I9b7a1c101e3c73d0270f9216225e5a13d9937b97 Reviewed-on: https://pdfium-review.googlesource.com/5332 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-05-11Rename render device classesDan Sinclair
This Cl renames the CFX_RenderDevice subclasses to make their usage clearer. Change-Id: Ie820b57df9a3743ce8c6893fb483b398a1f1bdbe Reviewed-on: https://pdfium-review.googlesource.com/5390 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-11Remove unused GetPlatformSurface and GetDC methodsdan sinclair
The times we need the DC we call ::GetDC to retrieve it from the platform. These methods are unused. Change-Id: If83aa9b37ae2231d8029db6f2e6d8d17f1825611 Reviewed-on: https://pdfium-review.googlesource.com/5350 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-11Do not use vector data() when it is emptyNicolas Pena
Before, all pointers were being initialized to 0. After raw pointers were changed to vectors, data() was used in some cases, but now no longer returns nullptr when it is supposed to. This CL fixes that. Bug: chromium:721417 Change-Id: Ia31b75b18dc17d7eed48538145fe5d0d59668843 Reviewed-on: https://pdfium-review.googlesource.com/5353 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-11Move map and codec loading into managerDan Sinclair
This Cl consolidates the code to load maps and codecs into the CPDF_ModuleMgr class instead of putting it directly into fpdfview. Change-Id: Ia08f212f43a33e51ab1c7832051ee4f28eecb50d Reviewed-on: https://pdfium-review.googlesource.com/5335 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-11Fixup Initialize spellingchromium/3097Dan Sinclair
Change-Id: Ibd8d70264d79afc0baabaa5093aceb21ee777196 Reviewed-on: https://pdfium-review.googlesource.com/5334 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-11Stop rendering if a span length overflowed in AGGNicolas Pena
In AGG, len is of type coord_type, which we have as int16_t, but we can add to it large values, causing it to become negative. Stop the rendering when that occurs. Bug: chromium:719258 Change-Id: Ic7497666b01220a9cd3e7d749f1fc6ae4a210870 Reviewed-on: https://pdfium-review.googlesource.com/5370 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-10Split DCT decoder creation from CPDF_DIBSource::CreateDecoder().Lei Zhang
Change-Id: Ia0ea49f0460fcb8e55542f237d321bb9207aa8e1 Reviewed-on: https://pdfium-review.googlesource.com/5250 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-05-10Replace operator bool with HasRef() in classes with a CFX_SharedCopyOnWrite ↵Lei Zhang
member. Change-Id: I51e30d298e87b9ae0d5aca83b2f1d6787efce70a Reviewed-on: https://pdfium-review.googlesource.com/5290 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-05-10Store the offset in the archive bufferDan Sinclair
This Cl moves the implementation of the archive buffer behind an IFX_ArchiveStream interface. The buffer holds the current offset and the offset parameter is removed from the CPDF_Creator and various other methods. Change-Id: Ia54e803b58bbfb6ef03fec4a940d2c056d541356 Reviewed-on: https://pdfium-review.googlesource.com/5255 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-10Cleaning up Edit codeDan Sinclair
This Cl conslidates if statements, converts int returns to bools where possible and various other cleanups in fpdfapi/edit. Change-Id: Ia31ecc69843117eb5ebfff449a6046a267d08e89 Reviewed-on: https://pdfium-review.googlesource.com/5190 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-10Cleanup CGifDecompressor part 2Nicolas Pena
Change-Id: I9754da8d1bf54b328761ac9d83fcc4a3518b4a73 Reviewed-on: https://pdfium-review.googlesource.com/5230 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-10Simplify CPDF_ImageRenderer::StartRenderDIBSource().Lei Zhang
Change-Id: Ia0a78be3320c5d6c3d0c40d4199cae1473e0e8dc Reviewed-on: https://pdfium-review.googlesource.com/5253 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-10Use FXSYS_IntToTwoHexChars() in more places.Lei Zhang
Change-Id: I84cd8e91a296119ecf80b7a092b886f291bebb45 Reviewed-on: https://pdfium-review.googlesource.com/4953 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-05-10Fix typos for the word start.Lei Zhang
Change-Id: Ic602126dc5407fcbb56dca5ec43e1824a5ca55b6 Reviewed-on: https://pdfium-review.googlesource.com/5251 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-05-09Create common CXML_Object base class for CXML_Content and CXML_Element.Tom Sepez
They should each know what they are rather than having an external ChildRecord struct to track the type. Change-Id: Ic647ba45569764073e944d30af1a96dccdc29eb3 Reviewed-on: https://pdfium-review.googlesource.com/5210 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-09Edit code cleanupDan Sinclair
Minor cleans in the fpdfapi/edit code. Change-Id: I7bb2f4add7c6e84f072501035b1f77c218174cca Reviewed-on: https://pdfium-review.googlesource.com/5152 Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-09Cleanup of CGifDecompressor part 1Nicolas Pena
This CL changes the tag_gif_decompress_struct into CGifDecompressor. It cleans up a bunch of unnecessary function pointers and starts cleaning up the members of the new class. Change-Id: Id49cd8f5377dc8daaa15118551dadad4ddde7931 Reviewed-on: https://pdfium-review.googlesource.com/5170 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-09Move FPDF_FILEWRITE adapter to own fileDan Sinclair
This Cl moves the adapater out of the fpdfsave.cpp file into its own h/cpp files. The adapter was renamed for clarity. The CPDF_Creator was modified to take the adapter as a constructor param and the Create methods consolidated. Change-Id: Icb104f195ef532dda053c859aae356a8d4a7a54c Reviewed-on: https://pdfium-review.googlesource.com/5151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-09Rename fpdf_edit_create.cpp to cpdf_creator.cppDan Sinclair
This Cl renames the fpdf_edit_create file to better match the cpdf_creator content. The CPDF_ObjectStream and CPDF_XRefStream code is moved out to their own .cpp files. Needed anonymous classes are split out as well. Change-Id: Ic83fb319ce28c816db82a4286e22032dc68811bc Reviewed-on: https://pdfium-review.googlesource.com/5171 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-05-09Use CXFA_TextUserData in place of CFX_Retainable where possible.Tom Sepez
Layering prevents the (newly-moved) CFX_Char from knowing about this class, so some casting is still required. Change-Id: I5b7556fdfa80d09e5116b171b01ab5e707763bf0 Reviewed-on: https://pdfium-review.googlesource.com/5172 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-09Remove editint.h and create individual headerschromium/3095Dan Sinclair
This Cl creates a cpdf_objectstream and cpdf_xrefstream headers from the editint header. Change-Id: I857981fa055ee9296cbd344860e55c67acf200ce Reviewed-on: https://pdfium-review.googlesource.com/5113 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-05-09Remove CPDF_Creator friendsDan Sinclair
This CL removes the friend declarations from CPDF_Creator and adds accessor methods instead. Change-Id: I6d8f67b5944aed34af00ff6ea9d23fe7d17cec18 Reviewed-on: https://pdfium-review.googlesource.com/5112 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-09Remove AppendObject from CPDF_CreatorDan Sinclair
The AppendObject method has been removed and the functionality moved to the individual CPDF_Object classes. Change-Id: I5446c6cc3e792d849acf77caed34b63a88f3a2d2 Reviewed-on: https://pdfium-review.googlesource.com/5072 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-09Cleanup CPDF_Creator defines and method namesDan Sinclair
This Cl removes un-needed prefixes from anonymous method names and cleans up various defines. Change-Id: If46a04c80460bb675af68d1e08d3093855d8fb19 Reviewed-on: https://pdfium-review.googlesource.com/5111 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-08Remove default params in CFX_DIBSourceNicolas Pena
Change-Id: I9306afed2747e3b0054adeea1d39916cac47f5c5 Reviewed-on: https://pdfium-review.googlesource.com/5091 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-08Check bits to decode will fit before decodingDan Sinclair
When decoding the CPDF_HintTable we read the dwDeltaGroupLen value out of the input stream which is a 16bit number. That value is then passed in to read a uint32_t of the object number. If we have a group length of > 32 bits we'll cause an undefined shift when we attempt to shift right more then 32 bits. This Cl bails out early if the dwDeltaGroupLen value is > 32 in order to stop the undefined shifts. Bug: chromium:718505 Change-Id: I919d6f4cd19826094a5e44d3a65d758029f5c236 Reviewed-on: https://pdfium-review.googlesource.com/5090 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-06core: allow building against system zlibMiklos Vajna
In a way similar to the existing USE_SYSTEM_LIBJPEG. The default is of course still the DEPS-based zlib checkout. Changes in v2: 1) Since Chromium doesn't have //third_party:zlib (AKA a "zlib" target in //third_party/BUILD.GN) all the targets that depended on //third_party:zlib now depend on third_party:zlib, which always points to PDFium's third_party/BUILD.GN. The targets that depended on //third_party:zlib in third_party/BUILD.GN just depend on :zlib instead. 2) Move the zlib bits out of !build_with_chromium block. Change-Id: Id73eb07591418ff2ae71b83b87c18af71b49a22a Reviewed-on: https://pdfium-review.googlesource.com/5030 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-05-06Remove type-unsafe void* / uint8_t* usage in fx_crypt.hTom Sepez
Consolidate all of the sha2 contexts while we're at it, the one with the largest buf is suitable for use by all the others. Change-Id: Iace6cd8ca4405f75f78842a1559c3a2478910218 Reviewed-on: https://pdfium-review.googlesource.com/4994 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-05Split out CPDF_CMap::m_pLeading into separate members.chromium/3093chromium/3092Tom Sepez
Avoid casting willy-nill over uint8_t*s, since there's at least one place where the wrong cast could be applied. Use std::vector<> as well. Use ByteRange struct to avoid the seg[i * 2 + 1] anti-pattern. Change-Id: I9278ccc3a545b2640f0daf101a0c8b1d5c5564f8 Reviewed-on: https://pdfium-review.googlesource.com/5012 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-05Cleanup CStretchEngine and its CWeightTableNicolas Pena
This CL cleans up a bunch of nits and improves ownership in the CStretchEngine class. Change-Id: I6527f29c50dab329ef58d0724cd24b94fca50ee6 Reviewed-on: https://pdfium-review.googlesource.com/4970 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-05Encode unicodes in UTF-16BE in ToUnicode mapNicolas Pena
Bug: pdfium:667 Change-Id: I811571c334ff28162905a65781ca14f03caf2966 Reviewed-on: https://pdfium-review.googlesource.com/4910 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-05Make CPDF_CMap::m_pMapping use std::vectorTom Sepez
Use much longer descriptive identifiers while at it. Pack a little tighter while at it, too. Change-Id: I123025f6433a627b5e00ee225efa7dc843b07913 Reviewed-on: https://pdfium-review.googlesource.com/5011 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-05More unused IFX_Pause parameters removedchromium/3091Dan Sinclair
Remove IFX_Pause parameters which are passed but not used. Change-Id: I51a491c7f9a429676d114a387390fac3ae65e187 Reviewed-on: https://pdfium-review.googlesource.com/4950 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-05Fix CPDF_CMap::m_pAddMapping lack of type information.Tom Sepez
Using a ByteBuffer and an array of uint8_t's isn't how one would represent an array of structured data. Packing uint16_t's into a uint32_t via / and % isn't ideal, either. Bug: Change-Id: Ib09ae2659ba2f027724546bb7aef99bdfd2dea25 Reviewed-on: https://pdfium-review.googlesource.com/4951 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-04Give a couple of char to int functions better names.chromium/3090Lei Zhang
- FXSYS_toDecimalDigit() becomes FXSYS_DecimalCharToInt(). - FXSYS_toHexDigit() becomes FXSYS_HexCharToInt(). Change-Id: If4683e8f85f05124b92ff075056cbc295442087d Reviewed-on: https://pdfium-review.googlesource.com/4930 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-05-04CPDF_Document::GetPageData() normally does not return NULL.Lei Zhang
Add a comment to clarify and remove some unneeded checks. Change-Id: I8b0492548b245abc45e161085047c9f36d6c8e2b Reviewed-on: https://pdfium-review.googlesource.com/4871 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-04Make CPDF_Font member variables protected.Lei Zhang
Change-Id: I5d452ea907f4d243645ddae3512776096a827522 Reviewed-on: https://pdfium-review.googlesource.com/4872 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-05-04Remove unused IFX_Pause memberDan Sinclair
The IFX_Pause param is stored but never used. Remove. Change-Id: I9e5298fc05c6d408873b7bee307a76dcf3d2d4da Reviewed-on: https://pdfium-review.googlesource.com/4931 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-04Cleanup CFX_CharMapDan Sinclair
This CL removes the CFX_CharMap class and moves the two static methods into the files in which they're used. Change-Id: I8ff7cbfd7f1ef3970e39c77ffa3439099f7fec02 Reviewed-on: https://pdfium-review.googlesource.com/4873 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-04Remove CFX_GlyphMapTom Sepez
It's only instantiated in one place, and then nothing is ever put into the map. Change-Id: I8ebee324e0ec63c139309275c8de115d38063dc6 Reviewed-on: https://pdfium-review.googlesource.com/4877 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>