summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cpdf_data_avail.cpp
AgeCommit message (Collapse)Author
2017-07-28Implement read validator.Artem Strygin
The wrapper for IFX_SeekableReadStream. Which allow us to check data availability on read request and request downloading of non available data on fly. Change-Id: I27c66cd58f43f8432f73104cc3f4c980515a9b56 Reviewed-on: https://pdfium-review.googlesource.com/9050 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: (OOO Jul 28 - Aug 8) dsinclair <dsinclair@chromium.org>
2017-07-26Remove recursion from CPDF_DataAvail::HaveResourceXXX.Artem Strygin
Change-Id: Iacac67bce99b4b4bcc303fb388aaf03f2f99e4f3 Reviewed-on: https://pdfium-review.googlesource.com/9070 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-07-26Remove useless code.Artem Strygin
Change-Id: Ibb7e33dddd79d6266961ebdf56600fc5a091dcb8 Reviewed-on: https://pdfium-review.googlesource.com/9071 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-07-20Use enum for pdf object typeArtem Strygin
Replace uint8_t type to enum for ObjectType variables Change-Id: Ie33c8c9413c5082397a2c6fbf73e03f08b7d8658 Reviewed-on: https://pdfium-review.googlesource.com/8470 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-04CPDF_DataAvail: avoid reads into stack buffers.Tom Sepez
Not a good practice even with correct bounds checks. Same idea for fpdf_edit_create.cpp Change-Id: I90b869ae4a07eb60d59997b9c5afc14830efc076 Reviewed-on: https://pdfium-review.googlesource.com/4830 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-03CPDF_SyntaxParser::SearchWord() is always backwards and for whole-wordsTom Sepez
Change-Id: Ic31d9cda5e919a754162e14e69cb63671a3fe8b9 Reviewed-on: https://pdfium-review.googlesource.com/4794 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-03SetPos to at most the file length to avoid overflowsNicolas Pena
This CL prevents arbitrary position setting which may cause integer overflows. In the bug in question, the PDF says the xrefs are located in a huge position. This then causes problems when calling CPDF_SyntaxParser methods. Bug: chromium:603545 Change-Id: I5f94c38f46a0217e9f12f1bf8b2f3bee3b03cb35 Reviewed-on: https://pdfium-review.googlesource.com/4813 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-04-26Remove a few more |new|s.Tom Sepez
Change-Id: I8a50ed680c1e101f855644fca8d282dd21470577 Reviewed-on: https://pdfium-review.googlesource.com/4533 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-04-20Convert IFX_MemoryStream to CFX_MemoryStreamDan Sinclair
The CFX_MemoryStream is the only implementation of IFX_MemoryStream. This CL removes the interfaces and uses CFX_MemoryStream directly. Change-Id: I2f43fa39e82dafa7673517d214ae15fd2d0df331 Reviewed-on: https://pdfium-review.googlesource.com/4391 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-04-20Cleanup the fx_extension code.Dan Sinclair
This CL cleans up the fx_extension file. The stream code was moved to fx_stream. IFX_FileAccess was removed and CFX_CRTFileAccess split to its own file. Code shuffled from header to cpp file. Change-Id: I700fdfcc9797cf4e8050cd9ba010ad8854feefbf Reviewed-on: https://pdfium-review.googlesource.com/4371 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-04-13Use vector of unique ptr in cpdf_data_avail.cpp.Tom Sepez
Remove member m_pAcroForm as it is only used in one method, and immediately set upon entry. A local will be fine here. Change-Id: I373f68252249a248061828530098ad759907259a Reviewed-on: https://pdfium-review.googlesource.com/4190 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-04-07Cleanup string passing in core/fpdf*Tom Sepez
Return strings where possible. Add missing consts to strings passed by ref. Convert non-const cases to pointers. Rename a few methods to be clearer. Change-Id: I86569bc1744f539e6dd67fc73649b272c016328c Reviewed-on: https://pdfium-review.googlesource.com/3951 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-03-22Return errors after validation instead of ASSERT in CPDF_DataAvailNicolas Pena
Change-Id: I909deca1d0bfc6de5ac0fd2e6956f9b918caf17a Reviewed-on: https://pdfium-review.googlesource.com/3157 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-22Fix ASSERT in CPDF_Data_AvailNicolas Pena
If ParseIndirectObjectAt fails, the replaced object will be null. So we can't ASSERT the output of ValidatePage. CL introducing the ASSERT: https://codereview.chromium.org/2483633002/ BUG=chromium:702897 Change-Id: Ib6e8c0bccaf2c05893f0abef27d431e112064865 Reviewed-on: https://pdfium-review.googlesource.com/3146 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-16Remove some nested statements in CPDF_DataAvail.Lei Zhang
Change-Id: I959dbfebdc7a5a1ec9b201a80ff6cfdc031572b0 Reviewed-on: https://pdfium-review.googlesource.com/2833 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-02-27Remove some pointless checks and assignments.Lei Zhang
Change-Id: I6f9fd67cdac581e8f91f829a5934b763bb229d21 Reviewed-on: https://pdfium-review.googlesource.com/2838 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-02-26core: fix two more uninitialized memberschromium/3025chromium/3024Miklos Vajna
Found by Coverity when scanning the bundled pdfium-3004 in LibreOffice. This fixes: - CID 1400335: Uninitialized members (UNINIT_CTOR) CPDF_DataAvail::m_dwTrailerOffset - CID 1400334: Uninitialized members (UNINIT_CTOR) CXML_Element::m_pParent Change-Id: I42da9a704ad75adf39c510c6ef89eb7a97860ea1 Reviewed-on: https://pdfium-review.googlesource.com/2670 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-01-09Remove CFX_ArrayTemplate from fpdfapitsepez
Review-Url: https://codereview.chromium.org/2611413002
2017-01-02Use vector of unique_ptrs for page node children.tsepez
Also be sure that a loop terminates without relying on specific behaviour of the callers. Review-Url: https://codereview.chromium.org/2598473002
2016-12-07Refcount all the IFX_ stream classes all the time.tsepez
We can remove a lot of "bOwnsStream" logic in the process. Always pass these by const reference, in case the called method wants to hang on to the stream (one exception is where we stick a raw pointer into a void* slot in a context from another layer). Review-Url: https://codereview.chromium.org/2451493002
2016-11-30Convert loose FX_Create* functions into static methodstsepez
Also remove a bool that is always false. Review-Url: https://codereview.chromium.org/2539203002
2016-11-18Make CPDF_Dictionary use unique pointers.chromium/2926tsepez
Some changes were required to match underlying ctors as invoked by the templated methods. Many release() calls go away, a few WrapUniques() are introduced to avoid going deeper into other code. Review-Url: https://codereview.chromium.org/2510223002
2016-11-16Make CPDF_Array take unique_ptrstsepez
BUG= Review-Url: https://codereview.chromium.org/2498223005
2016-11-09Do not load main cross ref table for first page in linearized pdf.art-snake
For the first page in linearized PDFs, it is not necessary to load the main xref table, because it have separate special xref table in the file header. This decreasing the time to show first page in PDF plugin. Review-Url: https://codereview.chromium.org/2483633002
2016-11-07Use unique_ptr return from CPDF_Parser::ParseIndirectObject()tsepez
In turn, propgate to callers. This introduces a few release() calls that will go away as more code is converted. It also removes a couple of WrapUnique calls that are no longer needed as ownership of the object flows along. Review-Url: https://codereview.chromium.org/2479303002
2016-11-07Rename CPDF_Linearized to CPDF_LinearizedHeadertsepez
My OCD insists that classes be named after nouns, and "linearized" feels like an adjective. Remove a redundant "if" while at it. Review-Url: https://codereview.chromium.org/2482973002
2016-11-07Reland of Unify some codeart-snake
Unify some code Move parsing of linearized header into separate CPDF_Linearized class. Original review: https://codereview.chromium.org/2466023002/ Revert review: https://codereview.chromium.org/2474283005/ Revert reason was: Breaking the chrome roll. See https://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_rel_ng/builds/331856 ___ Added Fix for fuzzers. Review-Url: https://codereview.chromium.org/2477213003
2016-11-04Revert of Unify some code (patchset #14 id:260001 of ↵chromium/2912chromium/2911dsinclair
https://codereview.chromium.org/2466023002/ ) Reason for revert: Breaking the chrome roll. See https://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_rel_ng/builds/331856 Original issue's description: > Unify some code > > Move parsing of linearized header into separate CPDF_Linearized class. > > Committed: https://pdfium.googlesource.com/pdfium/+/71333dc57ac7e4cf7963c83333730b3882ab371f TBR=thestig@chromium.org,brucedawson@chromium.org,art-snake@yandex-team.ru # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/2474283005
2016-11-04Unify some codeart-snake
Move parsing of linearized header into separate CPDF_Linearized class. Review-Url: https://codereview.chromium.org/2466023002
2016-11-04Pass object to ReplaceIndirectObjectIfHigherGeneration() by unique_ptr.tsepez
Review-Url: https://codereview.chromium.org/2477003002
2016-11-04Reland "Remove CPDF_Object::Release() in favor of direct delete"tsepez
This reverts commit f0d5b6c35fa343108a3ab7a25bc2cc2b3cf105b3. Review-Url: https://codereview.chromium.org/2478303002
2016-11-04Revert of Remove CPDF_Object::Release() in favor of direct delete (patchset ↵dsinclair
#11 id:200001 of https://codereview.chromium.org/2384883003/ ) Reason for revert: Looks like it's blocking the roll. https://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_compile_dbg_ng/builds/186619 Original issue's description: > Remove CPDF_Object::Release() in favor of direct delete > > Follow-on once we prove Release always deletes in previous CL. > > Committed: https://pdfium.googlesource.com/pdfium/+/4de3d095c9d9e961f93750cf1ebd489fd515be12 TBR=thestig@chromium.org,tsepez@chromium.org # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://codereview.chromium.org/2478253002
2016-11-03Remove CPDF_Object::Release() in favor of direct deletetsepez
Follow-on once we prove Release always deletes in previous CL. Review-Url: https://codereview.chromium.org/2384883003
2016-11-02Remove FX_BOOL from coretsepez
Review-Url: https://codereview.chromium.org/2477443002
2016-10-31Fix loading page using hint tables.art-snake
When linearized document have hint table, The FPDFAvail_IsPageAvail return true, but FPDF_LoadPage return nullptr, for non first pages. This happens, bacause document not use hint tables, to load page. To fix this, I force save the page's ObjNum in document. This is restoring of original fix: https://codereview.chromium.org/2437773003/ Review-Url: https://codereview.chromium.org/2444903002
2016-10-24Rename IFX_ stream nameschromium/2900tsepez
It's been troubling for some time that an IFX_FileStream might actually be an in-memory buffer with no backing file. Review-Url: https://codereview.chromium.org/2443723002
2016-10-21Revert of Fix loading page using hint tables. (patchset #5 id:80001 of ↵npm
https://codereview.chromium.org/2437773003/ ) Reason for revert: CPDF_DataAvail::IsPageAvail is causing crashes. BUG=chromium:658168, chromium:658170 Original issue's description: > Fix loading page using hint tables. > > When linearized document have hint table, > The FPDFAvail_IsPageAvail return true, but > FPDF_LoadPage return nullptr, for non first pages. > > This happens, bacause document not use hint tables, to load page. > > To fix this, I force save the page's ObjNum in document. > > R=npm, dsinclair > > Committed: https://pdfium.googlesource.com/pdfium/+/ef38283688c1ee7c08bcf4204cfb78e09c039782 TBR=dsinclair@chromium.org,tsepez@chromium.org,thestig@chromium.org,art-snake@yandex-team.ru # Skipping CQ checks because original CL landed less than 1 days ago. NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Review-Url: https://chromiumcodereview.appspot.com/2442663005
2016-10-20Fix loading page using hint tables.chromium/2897art-snake
When linearized document have hint table, The FPDFAvail_IsPageAvail return true, but FPDF_LoadPage return nullptr, for non first pages. This happens, bacause document not use hint tables, to load page. To fix this, I force save the page's ObjNum in document. R=npm, dsinclair Review-Url: https://chromiumcodereview.appspot.com/2437773003
2016-10-17Revert "Make CPDF_Object containers hold objects via unique pointers."tsepez
This reverts commit 1d023881cd53485303c0fcc0b5878e700dc470fd. Reason for revert -- fuzzers hit issues. TBR=thestig@chromium.org Review-Url: https://codereview.chromium.org/2425783002
2016-10-14Revert "Update CPDF_IndirectObjectHolder APIs for unique objects."Tom Sepez
This reverts commit 3ba098595ae56b64eacc0c25ab76b89a4d78d920. TBR=thestig@chromium.org,weili@chromium.org Review URL: https://codereview.chromium.org/2424533003 .
2016-10-14Update CPDF_IndirectObjectHolder APIs for unique objects.tsepez
Doing so highlights a few places where ownership is dubious. Add convenience functions to return an unowned reference to a newly-created indirect object. Review-Url: https://codereview.chromium.org/2419173002
2016-10-13Make CPDF_Object containers hold objects via unique pointers.tsepez
This tweaks the implementation while leaving the API the same. The API change is more disruptive, so break this part off first. Review-Url: https://codereview.chromium.org/2385293002
2016-10-12Get rid of CFX_ArrayTemplate<CPDF_Object*>tsepez
They won't work with std::unique_ptr down the road, so replace with std::vector. Review-Url: https://codereview.chromium.org/2411703003
2016-10-04Move core/fpdfapi/fpdf_parser to core/fpdfapi/parserdsinclair
BUG=pdfium:603 Review-Url: https://codereview.chromium.org/2392603004