summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-08-07Remove WideString::Format() from ThrowException() methods.chromium/3516Tom Sepez
No need for variadic printf-like functions, since callers can cobble arguments into a string much more simply. Change-Id: I0e8d6f6a55a3715ef9d5c6940b73ce8bb2220a1a Reviewed-on: https://pdfium-review.googlesource.com/39611 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-07Use wide string addition in place of some Format() calls.Tom Sepez
Simpler, faster, and avoids platform idiosyncracies of wprintf(). Change-Id: I91676bc38199ca2c30936094ca145239f915bc53 Reviewed-on: https://pdfium-review.googlesource.com/39610 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-07Add test for {Byte,Wide}String Operator+().Tom Sepez
Precursor to converting some Format() operations to simple string addition. Change-Id: I3a159f5ac548ea14586d87e7d56d1ec288898b0d Reviewed-on: https://pdfium-review.googlesource.com/39590 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-07Combine redundant CJBig2_Image code.Tom Sepez
Once upon a time, someone cut-n-pasted ~300 lines of code to avoid creating a default rectangle and to save a couple of additions. Then one path got one set of fixes (safe ints) and the other path got a second set of fixes (source bounds checks). Re-unify, picking up all the fixes, since they are identical otherwise. Change-Id: I099e854bc8ad027efabd5c2077c4319ee8221256 Reviewed-on: https://pdfium-review.googlesource.com/39550 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-07Speculative fix for null deref above ThrowNoDefaultPropertyExceptionTom Sepez
Avoid possibility of an unterminated string or nullptr by avoiding stringviews, since the non-view classes copy and always provide a suitable result. Always use %ls and widestrings in wprintf() variants, since that combination is consistent across our platforms (%s, %S, etc. have idiosyncracies). Bug: 870952 Change-Id: Ief62a42c3486e8298f9583b56e9333db1a74972a Reviewed-on: https://pdfium-review.googlesource.com/39551 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-06Avoid invalid object numbers in CPDF_Parser::LoadCrossRefV5().chromium/3515Lei Zhang
BUG=chromium:865272 Change-Id: I4606bdfd78ebd6553c36b985b4f49d07b579ac40 Reviewed-on: https://pdfium-review.googlesource.com/39438 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Art Snake <art-snake@yandex-team.ru>
2018-08-06Small optimization in CJBig2_Image::SubImage()Tom Sepez
We can use the memcpy() path whenever byte aligned. Split code into helper methods. Add test for fast path specifically. Change-Id: I52f6129b0e788eb2da60536cfa6fce12a0609375 Reviewed-on: https://pdfium-review.googlesource.com/39432 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-06Check for null object type in CPDF_Parser::LoadCrossRefV5().Lei Zhang
BUG=chromium:871042 Change-Id: Id4566b29270ab738c69d46cb96fc134485d6ee2f Reviewed-on: https://pdfium-review.googlesource.com/39510 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-06Do more CPDF_Parser::LoadCrossRefV5() cleanup.Lei Zhang
- Use range for-loop to avoid needing "i" and "j". - Avoid repeatedly calculating "startnum + j". - Reduce levels of nested ifs. - Remove variable that is only used once. Change-Id: I9d08cef1082812fcfaa2699f65720165c52ebcff Reviewed-on: https://pdfium-review.googlesource.com/39437 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-06Clean up a nit that was identified after CQing an earlier CLRyan Harrison
Change check to use empty instead of size <= 0. Also added a comment to the check to make it clear what is being guarded against BUG=chromium:863098 Change-Id: I993085c04ab66a9e2869c83d8fb48883ec0bbf71 Reviewed-on: https://pdfium-review.googlesource.com/39497 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-04Use more text object state in DrawTextPathWithPattern().chromium/3514chromium/3513chromium/3512Lei Zhang
BUG=chromium:668762 Change-Id: Iaf3fc9bcf68b8da2c947bbd78c5d72f78195b621 Reviewed-on: https://pdfium-review.googlesource.com/35991 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-04Clarify integer types in CPDF_Parser::LoadCrossRefV5().Lei Zhang
GetVarInt() returns uint32_t. So assign the results to variables of type uint32_t. Then make sure those results get passed on as uint32_t, or use pdfium::base::IsValueInRangeForNumericType<T>() to make sure they can be converted to type T safely. Change-Id: I4556f0b89b4e5cdb99ab530119c8051ec8a9411d Reviewed-on: https://pdfium-review.googlesource.com/39436 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-04Set the CPDF_Font doc / font dict in the ctor.Lei Zhang
Then we can mark the doc pointer as const because it never changes again. Also move initialization to headers when possible, add missing dtors, and fix some nits. Change-Id: I461affc8dce14d805b935fb4d8b5aaafb058a789 Reviewed-on: https://pdfium-review.googlesource.com/39413 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-04Do more CBA_FontMap initialization in the ctor and header.Lei Zhang
Change-Id: I705a49198a91b67aa403beea4446095a6a359259 Reviewed-on: https://pdfium-review.googlesource.com/39415 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-03Make CFX_XMLParser less permissiveRyan Harrison
Currently the parser will accept arbitrary garbage before the first element begins. This is causing issues with ClusterFuzz since it generates a lot of trash inputs which take a long time to parse inspite of being invalid. This CL adds in a check of how deep the parse is when dealing with text, and if it is at the top level scope, then only accept the beginning of the root node. BUG=chromium:863098 Change-Id: Ie45114ecf488f7e8a68a120d153033c7089d5cdc Reviewed-on: https://pdfium-review.googlesource.com/39470 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-08-02Use more helper macros/methods in JBig2_Image.cpp.Tom Sepez
Bundling the test with the accessor is a safer pattern than performing the check externally. Add test for CopyLine(). Change-Id: I7056bf33bdca40cb84a89e4928567a389d88ff1c Reviewed-on: https://pdfium-review.googlesource.com/39431 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-02Fix some nits in SkiaState.Lei Zhang
Change-Id: Id52bb57efea2a6a46bea645e4f3e54957982a40b Reviewed-on: https://pdfium-review.googlesource.com/39154 Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-02Skia Path: Fix text/xform size mismatch when calling drawTextRSXform().Lei Zhang
BUG=chromium:751423 Change-Id: I2fcc46b80e89cb651e255bd1fd2d6883a05cf9c7 Reviewed-on: https://pdfium-review.googlesource.com/39153 Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-02Tidy JBig2_Image.cppchromium/3511Tom Sepez
Add checked/unchecked GetLine(y) methods and use them. Introduce BIT_INDEX_TO_ALIGNED_BYTE() to de-mystify some shifting. Move local declarations to spot of use. Remove spurious Fill(), as we initialize to 0s. Initialize members in header where possible. Add unit tests. Change-Id: I41ccb91b57320dbc790fd0f680f6d98571280343 Reviewed-on: https://pdfium-review.googlesource.com/39370 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-02Handle inline font dicts in CBA_FontMap::AddFontToAnnotDict().Lei Zhang
BUG=chromium:869171 Change-Id: I0176bcafa8a63396d916916b5e10b96573085d04 Reviewed-on: https://pdfium-review.googlesource.com/39414 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-08-02Rework of CPDF_DataAvail::CheckHintTables.Artem Strygin
Move HintTables parsing logic into CPDF_HintTables. Change-Id: I9748179fe9fc3ac44f88c19c347e30c0e7e3ac67 Reviewed-on: https://pdfium-review.googlesource.com/38771 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-08-02Remove -Wno-pointer-to-int-cast from fxcodec target.Lei Zhang
Presumably, a libopenjpeg upgrade fixed third_party/libopenjpeg20/mct.c. Change-Id: I0e0e593b0cf7f32934ce45b19a54fe556b955448 Reviewed-on: https://pdfium-review.googlesource.com/39411 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-02Introduce JBIG2_PUTDWORD() macro in CJBIG2_Image.hTom Sepez
Provide symmetry with JBIG2_GETDWORD(). Avoid potential illegal undefined signed shift in JBIG2_GETDWORD(). Get better column alignment under cl-format via pointless shift by zeros for consistency. Change-Id: I13d46fe7976074e26df72b58a055788390191364 Reviewed-on: https://pdfium-review.googlesource.com/39430 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-02Remove some checks in IsLinearizedHeaderValid().Lei Zhang
One check can never fail. The other check can be done earlier, before creating the CPDF_LinearizedHeader. Change-Id: I0bccb2a9e19e0d5517daf96684adba6bb3a203bf Reviewed-on: https://pdfium-review.googlesource.com/39412 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-02Rework of CPDF_Parser::GetLastObjNum.Artem Strygin
Change-Id: I0481774858a9d9823580e1207807e35be8a9eea9 Reviewed-on: https://pdfium-review.googlesource.com/36270 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-08-02Mark some arrays as constant.Lei Zhang
Fix some nits as well. Change-Id: Iaef79056b68ea0dae7f76c09e7a133cc545896fd Reviewed-on: https://pdfium-review.googlesource.com/39353 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-08-02Simplify CFXJSE_FormCalcContext::unfoldArgs().Lei Zhang
Return results instead of writing them to an out parameter. Remove start index which is always 1. Change-Id: I4b969a1e27679fca56b2cde1a901a8967c7fa8ce Reviewed-on: https://pdfium-review.googlesource.com/39092 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-08-02Remove some parameters that are non-const references.Lei Zhang
Also remove a check that is always false, and simplify another check. Change-Id: I89193eebc84a6fd139b34b890a8c3003a635851b Reviewed-on: https://pdfium-review.googlesource.com/39091 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-08-01Replace more unchecked casts with type conversion funtions.Tom Sepez
Change-Id: If3eb4396232daed28f2b63ffe1d110075c9299de Reviewed-on: https://pdfium-review.googlesource.com/39230 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-01Bounds check lineSrc in JBig2_Image.cpp.Tom Sepez
No matter how the dimensions might be determined, we know the hard end of the source line, and can use it for a bounds check. We expect the size is quantized to a multiple of m_stride, so as long as each block operates within an m_stride, the initial check should be sufficient. Bug: 867501 Change-Id: Iaf9936557b856f3eb09fef522f3e6738aa4f38f0 Reviewed-on: https://pdfium-review.googlesource.com/39310 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-01Add in support for using .evt in make_expected.shRyan Harrison
BUG=pdfium:1024 Change-Id: If7e00eb4f6ebf6499be20e88bfc9b2ac35f2d797 Reviewed-on: https://pdfium-review.googlesource.com/39390 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-08-01Make FPDF_FormHandle be represented as an incomplete type.chromium/3510Tom Sepez
Make consistent with other public API types. Introduce CPDFSDKFormFillEnvironmentFromFPDFFormHandle() and FPDFFormHandleFromCPDFSDKFormFillEnvironment() helper functions. Use these to kill off some casts in the process. Change-Id: I6230ecdb4cecd03076f5e24c8cc49c45ad694da7 Reviewed-on: https://pdfium-review.googlesource.com/39250 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-01Encapsulate some public static methods in CFXJSE_FormCalcContext.Lei Zhang
They are only used inside CFXJSE_FormCalcContext. Move into an anonymous namespace. Change-Id: Ib8a0ff9b90cf951459c04655bedada3bdb1979a4 Reviewed-on: https://pdfium-review.googlesource.com/39090 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-08-01Fix assertion in opj_j2k_merge_ppt().Lei Zhang
This patches in: https://github.com/uclouvain/openjpeg/commit/832dfd18 https://github.com/uclouvain/openjpeg/commit/0c913b0a Also clean up a duplicate patch number and update README.pdfium. BUG=chromium:614691 Change-Id: I282abfe227e2f667418e5d9058e96e253b220de7 Reviewed-on: https://pdfium-review.googlesource.com/39352 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-01Refactor PatternStringType().Lei Zhang
Return a std::pair instead of having a non-const ref out parameter. Use early returns / continues to simplify code. Change-Id: I093fe667d31447ed42b8d44e354405094adaf8fd Reviewed-on: https://pdfium-review.googlesource.com/39070 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-01Roll third_party/freetype/src/ b532d7ce7..578bcf103 (28 commits)Lei Zhang
https://chromium.googlesource.com/chromium/src/third_party/freetype2.git/+log/b532d7ce708c..578bcf103a12 BUG=pdfium:1125 Change-Id: I6cf423c4e64e54c05c47e7f706039ef2d4ef49dc Reviewed-on: https://pdfium-review.googlesource.com/39350 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-01Fix sign mismatch in CPDFSDK_FormFillEnvironment::GetPageViewCount().Lei Zhang
Also initialize members in the header when possible. Change-Id: I458bc433f79ac2f6c04d645f44db6f460fd0bdc1 Reviewed-on: https://pdfium-review.googlesource.com/39330 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-01Rename PageSetContainerLayoutItem to TraverseStrategy_PageSet.chromium/3509Tom Sepez
Provides consistency with the naming of other traverse strategies. Fix dubious casting inside the strategy. Change-Id: Ic96b1922ae1dc601a37c8c3b3dd0f118ab6b2eea Reviewed-on: https://pdfium-review.googlesource.com/39210 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-01Add a ScopedLocale for use within CXFA_LocaleValue.Lei Zhang
Add more checks for |m_pLocaleMgr| before dereferencing it. Change-Id: I39ab44d652364f5530266d2b724fa6703d1b51f1 Reviewed-on: https://pdfium-review.googlesource.com/39114 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-08-01Mark CFGAS_FormatString methods as const.Lei Zhang
Change-Id: I7809f2648d24b4ae0dd1a5a0d4fd98a0bd4d8939 Reviewed-on: https://pdfium-review.googlesource.com/39113 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-08-01Combine date/time format methods in CFXJSE_FormCalcContext.Lei Zhang
Also fix C++ style errors. Change-Id: Ia4b815c2fa8430791bb44a218ef93f8efde8c3af Reviewed-on: https://pdfium-review.googlesource.com/39050 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-08-01Fix a nullptr crash in CXFA_LocaleValue::ValidateValue().Lei Zhang
Fix some nits as well. BUG=chromium:868271 Change-Id: Ia3231fde98c3e16e41b092a9833402cedc8e828d Reviewed-on: https://pdfium-review.googlesource.com/39112 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-01Add FPDFText_GetFontName() APIMiklos Vajna
This follows the same pattern as DefaultGetFaceName(), so the client has to call this function twice, but allocation of the string buffer happens outside pdfium. Change-Id: I06b7dcd00aca9b9b94799dad3f139617d7f5451e Reviewed-on: https://pdfium-review.googlesource.com/38870 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-07-31Remove CXFA_Corner downcasts from cxfa_rectangle.cppTom Sepez
We don't need anything that the parent class can't provide, so avoid dubious casting. Change-Id: I9f3d9735f3bfbcf005865772af31817c2b8addef Reviewed-on: https://pdfium-review.googlesource.com/39270 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-30Replace m_bIsContentLayoutItem with proper enum for type.Tom Sepez
Because bools are bogus. Change-Id: I54a2627443784cec40912288230e657c63a35408 Reviewed-on: https://pdfium-review.googlesource.com/39190 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-30Don't static_cast<>(this) to subclass in CXFA_LayoutItem methods.chromium/3508Tom Sepez
Instead, move the methods to the subclass where they belong. Fix IWYU in CJX_Object.h to fix compilation. Change-Id: I4c71f28235b9cf5000e9ddaf33d6602baf22205f Reviewed-on: https://pdfium-review.googlesource.com/39170 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-30Return unique_ptr from CXFA_FFNotify::OnCreate{Container,Content}LayoutItem()Tom Sepez
... and then immediately release it, but it is a step in the right direction. Change-Id: Ib52972c6789d8f98a576d1c69f8019541c96ac51 Reviewed-on: https://pdfium-review.googlesource.com/39152 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-30Convert some asserts to ifs in cxfa_ffnotify.cpp.Tom Sepez
We'll get a nice safe segv should this somehow happen in the wild instead of a type confusion error. We'll assert later on in the debug builds when the null is seen, as well. Change-Id: Iabd8468adcbacaa0acdc7c68f27cc8f94e0e68cc Reviewed-on: https://pdfium-review.googlesource.com/39151 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-30Type-safe iteration over CXFA_ContentLayoutItems.Tom Sepez
There's no reason that every CXFA_LayoutItem must be a CXFA_ContentLayout item, so use checked conversions. The code may already be arranging things so the constraint is already satisfied, but this adds an additional layer of safety. Tidy some long expressions with pre-existing typedef for node iterator while we're at it. Change-Id: If1448131ca73bfedb2266b070f1a913688598e64 Reviewed-on: https://pdfium-review.googlesource.com/39051 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-30Fix a misspelling of "locale".Lei Zhang
Change-Id: I3fdc6d473f08835b6caeacbbd583bb651a9c5678 Reviewed-on: https://pdfium-review.googlesource.com/39111 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>