summaryrefslogtreecommitdiff
path: root/core
AgeCommit message (Collapse)Author
2018-09-06Fix integer overflow in LoadCryptInfo.Henrique Nakashima
Bug: 847283 Change-Id: I7951103a5a425407b5375460a5556e8765430740 Reviewed-on: https://pdfium-review.googlesource.com/42090 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-09-04Consolidate some common code in ccoded_progressivedecoder.Tom Sepez
Small consolidation before trying to fix a memory issue. Unfortunately, this involves converting a switch -> ifs, since we no longer dispatch exactly the same. Change-Id: I7ef61db98cdfbbc983adf21e7b3fe4ef1d2ce869 Reviewed-on: https://pdfium-review.googlesource.com/41830 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-09-04Fix some more span/memcpy interactions.Tom Sepez
Use the preferred idiom of creating a subspan, which makes the proper checks prior to the copy. Change-Id: Ia7f25b5760dea5707df66cf421195b23a1ce0ad0 Reviewed-on: https://pdfium-review.googlesource.com/41911 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-04Avoid CHECK in fpdf_parser_decode.cpp (memcpy empty span)Tom Sepez
Given a span of size N, memcpy(dest, &span[N], 0) ought to be a no-op, but since we compute span[N] before checking for zero length, we hit an assert. The correct idiom should be to create a sub-span, which allows specifying N, but only when the size is 0. Bug: 879910 Change-Id: Ic6f368109a5c2f1e13a5f638c6a233769e2ad41b Reviewed-on: https://pdfium-review.googlesource.com/41930 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-04Remove unneeded fpdf_parser_decode.h #includes.Lei Zhang
Change-Id: I2c52828c25b4941669503328517c12a0a1dd770e Reviewed-on: https://pdfium-review.googlesource.com/41850 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-31Remove avail_buf out argument from GetAvailInput() methods.chromium/3542chromium/3541chromium/3540chromium/3539Tom Sepez
It's always passed as nullptr. It's a good thing, too, since it looks like some of the implementations are returning a wrong pointer. Add some missing |const|s. Change-Id: I768048fdfe4cdd1dc838fee26fec18e024e39920 Reviewed-on: https://pdfium-review.googlesource.com/41810 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-31Simplify radial shading.Henrique Nakashima
Change-Id: I3b6a386cf376a418ad64514313c791437ea54cf6 Reviewed-on: https://pdfium-review.googlesource.com/41610 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-31Fix radial shading when start circle is a point in the center of end circle.Henrique Nakashima
The bug also requires end circle to be tiny (radius of < 0.01). Bug: pdfium:1140 Change-Id: I2b355f44f0383334b8988fe41f82cb3f587e9909 Reviewed-on: https://pdfium-review.googlesource.com/41672 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-08-30Add unit test for AutoRestorer<> on smart pointer types.Tom Sepez
Test UnownedPtr<> and RetainPtr<>. We cannot operate against std::unique_ptr<> because we need a copyable type. Add test for self-reassignment on going out of scope. Move one test helper class to testing/ so it can be shared among unit tests. Allow it to recognize if it ever gets "destroyed", otherwise we can't be sure Retain/Release applied in the correct order. Change-Id: I13056094c70079f7283cbc7600948f81a64874b4 Reviewed-on: https://pdfium-review.googlesource.com/41690 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-30Use pdfium::span<> arg in A85 and RLE encoder methodsTom Sepez
Change-Id: Iff900bc3e1cd9c9dd6b023230c1feba78759581c Reviewed-on: https://pdfium-review.googlesource.com/41710 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-30Use span<> in CFX_FontMgrTom Sepez
Change-Id: I3f811b20399efac1b511e75d950699eee7192c65 Reviewed-on: https://pdfium-review.googlesource.com/41650 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-30Fix lifetime issue in CCodec_ProgressiveDecoder.Tom Sepez
The associated bug is caused by failure to clean up context before returing at line 740 or so. But cleanups are fragile, so instead do not move context out of a local until success. This in turn means passing the local to one helper rather that using the stored value and confirming this is the only helper method invoked during the time in which the context is not yet stored. Bug: 879025 Change-Id: I1acb438edc28f7f4dd8acccc2461fe3a5ea7f5c8 Reviewed-on: https://pdfium-review.googlesource.com/41670 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-29Use pdfium::span<>/UnownedPtr in CFX_Font.Tom Sepez
Move some platform-specific ifdefs so the come last in each section as it is easier to read, perhaps. Change-Id: Ic1c2652c46ecebc63b66213735ed6d94737a7f32 Reviewed-on: https://pdfium-review.googlesource.com/41630 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-29Fix radial shading when center of start point is on the border of an end circle.Henrique Nakashima
Radial shading is done between two circles with their own centers and radii. When one has a radius of 0 and is located on or very close to the border of the other circle, a should be 0, but is not due to rounding errors unless the circles are aligned in x or y. Bug: pdfium:1140 Change-Id: Ief2efa91f3f16f7bed439aa471b258fa4d680acf Reviewed-on: https://pdfium-review.googlesource.com/41590 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-08-29Remove FPDFDOC_ prefix from non-public functionsTom Sepez
Second CL for naming consistency. Bug: pdfium:1141 Change-Id: Idf0a0da52abd68648ab709997e0523ee3240c247 Reviewed-on: https://pdfium-review.googlesource.com/41531 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-29Use pdfium::span<> in fpdf_parser_decode.h helper functions.Tom Sepez
Change-Id: Ib0a2bd21fe4304163cf9c080e07475e7c033c299 Reviewed-on: https://pdfium-review.googlesource.com/41570 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-29Remove FPDFAPI_ prefix from internal cid/encoder functionsTom Sepez
These look too much like public/ FPDF functions otherwise and yet they are not exposed anywhere beyond core/fpdfapi. Disambiguate one method vs. top-level function usage as a result. Bug: pdfium:1141 Change-Id: I9cfdfced90386bb9ef6b2b86f568f2e6f8ee6a5a Reviewed-on: https://pdfium-review.googlesource.com/41530 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-28Use pdfium::span<> in more image modulesTom Sepez
Change-Id: Ie344bb37abf7dde158d03cc2897dca3588f1a5e3 Reviewed-on: https://pdfium-review.googlesource.com/41550 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-28Rename remaining fx_codec*.cpp to match class and .h file nameTom Sepez
Then include headers in the proper order per standards, since it will no longer trigger a presubmit warning. Change-Id: I6bb86ac90e8fd9aed30b66dac61726f0dea8222c Reviewed-on: https://pdfium-review.googlesource.com/41535 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-28Use std::span<> in CCodec_JPEGModuleTom Sepez
Also rename .cpp file to match class name and .h file. Modify some helper functions to operate on spans. Move some initializations to member declarations. Change-Id: Ie0889bda91daaef80fae6f5681f8ce068e92453b Reviewed-on: https://pdfium-review.googlesource.com/41534 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-28Handle non-printing characters at beginning of extraction regionRyan Harrison
Currently if a text extraction region begins on a non-printing character then "" will be returned. This is the incorrect behaviour, instead the call should scan ahead until a printing character is found and start extracting from there. Also proactively adds a similar check and scan for the end of the extraction region. BUG=pdfium:1139 Change-Id: Ia2001ac89740f3d31d2bb69e8000773f8b01091b Reviewed-on: https://pdfium-review.googlesource.com/41532 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-08-28Let CCodec_ProgressiveDecoder::m_pSrcBuf outlive contextsTom Sepez
This requires making some members unique_ptr<> to preserve the destruction order. Bug: 877766 Change-Id: I69e0173fdde7e9cd0d24017d6c829b9b9cf600c0 Reviewed-on: https://pdfium-review.googlesource.com/41490 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-27Rework CCODEC_ProgressiveDecoder.Tom Sepez
Rename .cpp file to match class and .h file (!!!) Put initialziations into header. Change-Id: I2cbc7608287f8df887ce186d122dcd3db2aef19b Reviewed-on: https://pdfium-review.googlesource.com/41511 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-27Use pdfium::span<> in CCodec_RLScanlineDecoderTom Sepez
Change-Id: I3dc2dd54d89858722c2aea4b9e694308796b8274 Reviewed-on: https://pdfium-review.googlesource.com/41510 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-27The final game: mark everything final.Tom Sepez
Then revert the ones that break compilation. Fix one IWYU noticed during presubmit. Change-Id: I881a8a72818e55dbc4816247e35ff5e3015194e7 Reviewed-on: https://pdfium-review.googlesource.com/41470 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-27Remove unnecessary ToArray() calls and locals in CPDF_Dest.chromium/3535Lei Zhang
Rename GetObject() to GetArray() and remove more ToArray() calls. Change-Id: I754ca72b32c085e1801d3cedcd291ce4d2682359 Reviewed-on: https://pdfium-review.googlesource.com/41353 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-08-25More cleanup in CPDF_TextPagechromium/3534chromium/3533Nicolas Pena
Change-Id: I6630ccdcce795c2f4767f5403303b5cd670c93ea Reviewed-on: https://pdfium-review.googlesource.com/41351 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-08-24Rename CFX_DIBSource to CFX_DIBBase.Tom Sepez
It is not a source from which you can get CFX_DIBs, but rather a base class from which all DIBs inherit. Do the same thing for the CPDF_DIBSource wrapper class. Mechanical change apart from adding a one-line comment in cfx_dibbase.h Change-Id: Id2bde87813ca301d9fafc55ce08d703dfc6a7184 Reviewed-on: https://pdfium-review.googlesource.com/41352 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-24Use span<uint8_t> in more fxcodec code.Tom Sepez
There are also small tweaks in tests to ensure strict order of stack variable lifetimes. Change-Id: Ic9d5c6a2bdd378b517be627f8e29f725bafdc2ad Reviewed-on: https://pdfium-review.googlesource.com/41310 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-24Cleanup CalculateBaseSpace in CPDF_TextPageNicolas Pena
Change-Id: Iaa3e8d88083d7ac15762ff2d5d74a378f626483c Reviewed-on: https://pdfium-review.googlesource.com/41350 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-08-24Change CPDF_MetadataTest test data to static const char data[].Lei Zhang
Change-Id: Ifdc931fbaecf42249351bbc78760ed2c1b6566c1 Reviewed-on: https://pdfium-review.googlesource.com/41291 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-23Use pdfium::span<> in CPDF_Stream::SetData().Tom Sepez
Conversion to span makes this more elegant in a number of places, owing to std::vector directly converting to span, and the bytestring's ToRawSpan(). Disambiguate single-argument forms to allow passing {} as an argument. Change-Id: Ibd5eaadca8d8cbbd589338f375c7ee8439fd3eb2 Reviewed-on: https://pdfium-review.googlesource.com/41272 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-23Pass unique_ptr<> to CFX_MemoryStream constructorTom Sepez
Proves we own the memory that the class will eventually free. Change-Id: Ie9523da8db738e7478a1c73e3e1a6b24aed38442 Reviewed-on: https://pdfium-review.googlesource.com/41290 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-23Fix GCC build with V8 disabled.Lei Zhang
- Remove set, but otherwise unused variables. - Mark some pdfium_test code as V8-enabled only. - Do not build one unit test with GCC. Change-Id: I3f04273a7731086e08386478a62769bf06f6d8a4 Reviewed-on: https://pdfium-review.googlesource.com/41271 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-23Fix shadowed variablesRyan Harrison
This CL fixes instances of variable shadowing that are discovered by turning on -Wshadow. BUG=pdfium:1137 Change-Id: I418d50de89ecbeb12e85b23a358bc61e8f16e888 Reviewed-on: https://pdfium-review.googlesource.com/41150 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-08-23Remove deprecated FPDFDest_GetPageIndex() API.Lei Zhang
Use FPDFDest_GetDestPageIndex() instead. BUG=pdfium:1041 Change-Id: I8e91ef46456a60ebd873068765b7c3ff1a991fa4 Reviewed-on: https://pdfium-review.googlesource.com/41230 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-23Cleanup CPDF_TextPage::GetRectArrayNicolas Pena
Change-Id: I12b418b06b097af87f1143dbda3b6e304ba437c6 Reviewed-on: https://pdfium-review.googlesource.com/41210 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-08-23Remove bool bPromptCJK argument (several places)Tom Sepez
It gets computed, and passed around, but in the end no decisions are made because of it. Change-Id: If67f6f0cd0c37e52993832be1fb83498fd851914 Reviewed-on: https://pdfium-review.googlesource.com/41190 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-23Fold CPDF_Document::LoadDocInternal() into caller.Tom Sepez
It is only called in one place. It also has a superfluous test and return as it is currently written introduced in https://pdfium-review.googlesource.com/c/pdfium/+/35490 Change-Id: Iba1aaac6e93c261f71729f39e51741f19c5dbb57 Reviewed-on: https://pdfium-review.googlesource.com/41071 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-22Properly handle language markers in decoded textRyan Harrison
In text like document title 0x001B is used as a marker for the beginning/end of a language metadata section. Currently PDFium does nothing with this data, but when returning the 'decoded' text it needs to be stripped out. The existing code assumed that the two bytes following a marker would be the data to be removed and did nothing to track if it was in/out of one of these regions. This led to a situation where it would always strip the two bytes following the region, since it assumed the end marker was the beginning of a new region. This CL corrects the detection and handling of these regions, and adds a regression test for the reported bug. BUG=pdfium:182 Change-Id: I92ddba5666274a8986fed03f502a0331f150f7ac Reviewed-on: https://pdfium-review.googlesource.com/41070 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-08-22Use UnownedPtr<> in JBig2_TrdProc, part 2.Tom Sepez
Re-order some locals to obey strict lifetime constraint. Pack a little tighter. Change-Id: Iae011d21b934fac865cf10ac20c046c8917d3a98 Reviewed-on: https://pdfium-review.googlesource.com/40915 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-22Mark CFX_XMLNode pointers as const in various places.Lei Zhang
Change-Id: I86c6f7526e2ef4c3e8de30ebaff223095ee70fc4 Reviewed-on: https://pdfium-review.googlesource.com/40811 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-08-22Fix integer overflow in CPDF_CIDFont::GetCharBBoxNicolas Pena
Bug: chromium:875924 Change-Id: I85c86d3f90ee62b5593b0b20e44283c5056702ff Reviewed-on: https://pdfium-review.googlesource.com/40730 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-08-22Simplify GetEmbeddedObj() methods.Lei Zhang
Change-Id: I976a8841f1519310cbf934103336dc050a7c293d Reviewed-on: https://pdfium-review.googlesource.com/40773 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-08-21Use UnownedPtr in CPDF_VariableTextTom Sepez
Re-arrange order of some variables so that the lifetime constraints are not violated, even temporarilly. Change-Id: I859f1217d5af0f4c703a3d8ed742c1f144cc1c61 Reviewed-on: https://pdfium-review.googlesource.com/40950 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-21Use UnownedPtr<> in JBIG2_SDDProc.Tom Sepez
Pack a little tighter while at it. Change-Id: If7cbb324ebf828a4bb60eb364fc3e0f31625e57f Reviewed-on: https://pdfium-review.googlesource.com/40913 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-21Use UnownedPtr<> in JBig2_GrrdProc.h.Tom Sepez
Change-Id: Ie3502443b801ae4af6e4c9e533f28d102703104c Reviewed-on: https://pdfium-review.googlesource.com/40912 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-21Use UnownedPtr<> in CJBig2_TRDProc.Tom Sepez
First real use case of assigning Unowned to MaybeOwned. Change-Id: Ia5bc7102012f7a09120ba02d38cf751547d5c005 Reviewed-on: https://pdfium-review.googlesource.com/40914 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-21Avoid copying some big vectors in JBIG2_SymbolDictTom Sepez
Change-Id: I662f65b53a1a17be0062c92452d82acbbe157477 Reviewed-on: https://pdfium-review.googlesource.com/40910 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-21Fix lifetime issue in CJBig2_GRDProc::ProgressiveArithDecodeStateTom Sepez
Bug: 876222 Change-Id: I56c20c006ee26650f32b9ec90f3c7f91466b7470 Reviewed-on: https://pdfium-review.googlesource.com/40890 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>