Define a symbol indicating it is present, and then use it to
condition plugin-specific definitions so as to avoid breaking
(future) builds against off-the-shelf clang compilers, as
plugin-only #pragma syntax may be added.
Change-Id: Ia485f9ed56705f2bf9506c9ba868b6b4515aca52
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118273
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
There isn't any reason to trust a programmer-provided length vs.
those deduced by the compiler.
-- Re-write some cases to use subspan where possible.
-- Flag the rest as UNSAFE_BUFFERS().
Change-Id: I8d2fded1c473c5320fca034e0d66b110071076a7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118250
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
This should make rolling instrumented_libs easier in the future
since hooks don't also have to be updated.
Change-Id: I3de979f251702c1421b4a426168a71002bd4ea76
Bug: 320564950
R=thestig
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118230
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Auto-Submit: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
e5ff2eff3b..e4eef53d5b
Pick up change at 8d897a51bd1726d0dfc5a8ebbb15ee141415dbae to move GN
arg clang_unsafe_buffers_paths to BUILDCONFIG.gn.
Created with:
roll-dep build
Change-Id: I7e6e837062e1d2fcdb7369c5a82d8782cd6a17fb
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118170
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
-- convert to std::array<> where indexing required.
-- use spans of chars in place of C-style pointer.
Change-Id: I41804397a4a8e4913f13e38c00bc19e6d1e4e58b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118110
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Specifying an explicit length to make_span() should be treated
as an unsafe operation.
-- move arrays themselves into anonymous namespaces.
Change-Id: I9f32dd25de20784f7061618a09221e0b5b3bd611
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118150
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
-- convert to std::array<>, or
-- avoid indexing with range-based loop, or
-- mark two routines UNSAFE.
Change-Id: I5f2ed1819d139c82e69e89c7502ccfa931d1cdf2
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118074
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
The original v8 interceptor API has been deprecated. Update the code to
use the new API.
Change-Id: Icf5a2f2f4bd045d48c8a2143e2cdaa14964d27e0
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117936
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
In ByteStringView.TrimmedRight, there exists a variable that should be
used on the next line, but is not due to a typo. Put the variable to
use. Do the same for the WideStringView version of the test.
Change-Id: If47e56271003d8cfb3e381c967e5a1a97fb3c166
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118073
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
-- use std::array<> where useful.
-- use pdfium::contains() to avoid indexing otherwise.
Change-Id: I7c2ba4c6f71ab6ae94822a711c322ee1658ac82c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/118070
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Avoid writing out color values that violate the PDF spec.
Change-Id: I1a7b52407bedfbea443a306906e32236473addbe
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117396
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
This will allow the entire directory to be included into
UNSAFE checks once the format of the paths.txt file matures.
Change-Id: Ia57ebf136e7cdf7ce73928230a223884135a80d9
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117933
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
FPDFPage_Delete() may not work as expected when used in conjunction with
FPDF_SaveAsCopy(). The CPDF_Creator code that saves the PDF does not
understand the structure of the document's page tree. Therefore, it
only looks at references to determine whether to save referenced
objects, or to discard orphaned objects. This becomes a problem when
bookmarks or other objects has references to page objects, as the page
objects are not considered orphaned.
Fix this problem by augmenting the page deletion code in CPDF_Document.
After a page has been deleted, check to see if there are any references
to the page in the page tree. If it is no longer in the page tree,
replace it with an object of type null.
Since it is likely impossible to traverse the entire PDF's object tree
and correctly remove all the references to a page, use the null object
type to null out the page is the best way to effectively remove it,
while preventing references to it from dangling. Objects that become
orphaned as a result of this modification, such as the page content
stream, will be pruned by CPDF_Creator.
Bug: pdfium:2146
Change-Id: I474ff921e2239f27652f5308b56d1c1b74b51d77
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117910
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Use FX_RGB consistently for color representation.
Change-Id: I282232f7eb6b91816af068edd152dccd46364596
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117391
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Consistently use this struct instead of std::array.
Change-Id: I9ccfd55834bc0a118d9e6c937604be6796005522
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117817
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Add a way to represent the RGB channels, with easy access to the color
components.
Change-Id: I051482e9e60ac73d3a1b73e6eeaa8b355d6f34be
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117816
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
The code is already clean with respect to UNSAFE_BUFFERS.
Change-Id: I0076c7ec9210e16cc186119bb4a8f27bd68098f7
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117815
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
The code only ever uses the values at [N][1].
-- convert to std::array while at it.
Change-Id: I94ace32fb6b9d936394992619e138620eaef764b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117857
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Currently, this always copies, but we can avoid this in many (not all)
cases with a subsequent CL. There is a slight difference with large
numbers, so this is a check that thing still render properly.
Change-Id: Id4c9d061ed69ca59c5fed0e31cd5feb4574c5e6f
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117331
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Exercise FPDFPage_Delete() followed by FPDF_SaveAsCopy() under a variety
of situations. Show that FPDF_SaveAsCopy() is writing out more data than
necessary.
Bug: pdfium:2146
Change-Id: Ic520acc6a86fbf9b14854e3ba4d2b1ee71fa904b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117770
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Add the nodiscard attribute to CFX_DIBitmap::Create(). Then change all
callers that did not check the return result to do so. Fail gracefully
when it obvious how to do so. Otherwise wrap the Create() call with
CHECK().
Change-Id: Ibab42b2306e8f8a93d8d87472fcec0cb3250df73
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/115412
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
This CL creates a new pdfium_unsafe_buffers_paths.txt in the
top-level directory which lists which sub-directories have been
made safe against C-style pointer arithmetic.
Change-Id: Ibe3e7bc2e3e85e573119a6123c93bc70d91f0330
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117850
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Manual roll to pick up changes related to unsafe-buffers.
e9a12f2766..e5ff2eff3b
Created with:
roll-dep build
Change-Id: I2a464f7205f34cf5870f156d95cb40e034a4fd37
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117810
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
-- Suppress enforcement in tests.
-- Also add one missing case in span.h
Change-Id: Ib5a52d858a67545618099bd745a0a173b4a2c2ca
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117811
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Use std::array<float, 3> consistently for color representation.
Also mark some CPDF_MeshStream methods as const.
Change-Id: I0c80cd34d916615b46525d260b1b9501e638f3fa
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117390
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Thomas Sepez <tsepez@google.com>
Use pdfium::ClampSub() to avoid undefined behavior in some DrawGouraud()
calculations. The exact result is not critical, as it only affects pixel
values.
Bug: chromium:40813106
Change-Id: I7eaecb1f64fa1c4f46c051280337f0d414a582f0
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117730
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
- Mark some references as const-ref.
- Consolidate repeated calculations.
Change-Id: I459f3602dce352deaf9d61e667967ce0446a98cd
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/117710
Reviewed-by: Thomas Sepez <tsepez@google.com>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>