Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8ebce9f
Roll Memory Tools from 3d4610fc0dd4 to db1b13009b4a (5 revisions)
Nov 9, 2026
96b71fa
Roll Depot Tools from a03dfbf7f2d1 to 96a7c1418eed (125 revisions)
Nov 9, 2026
e24d49c
Add span-based wrapper functions for libyuv calls
leizleiz Nov 9, 2026
57726ee
Fixes scalar build for cfx_scanlinecompositor_hwy
amd-nithyavs Nov 9, 2026
144dfc5
Delete unused CPDF_IconFit copy ctor
leizleiz Nov 9, 2026
0880b61
Add unit tests for CPDF_IconFit
tsepez Nov 9, 2026
a6d2653
Clear render context in FPDFPage_GenerateContent
tsepez Nov 9, 2026
fc08db6
Use GCedVector for resolve processor candidate collections
tsepez Nov 9, 2026
8859834
Borrow Chromium's base::Extend()
leizleiz Nov 9, 2026
701bec9
Switch C-arrays constants inside fx_unicode.cpp to std::array
leizleiz Nov 9, 2026
c0643c7
Add unit tests for fx_date_helpers
tsepez Nov 9, 2026
ec2df7e
Get rid of count variables inside cfx_scanlinecompositor_hwy.cpp
leizleiz Nov 10, 2026
2697090
Fix UNSAFE_TODO() in CPDF_Image::SetImage()
leizleiz Nov 10, 2026
e3fba83
Reduce total number of persistents in cfxjse_engine.h
tsepez Nov 10, 2026
b2c765e
Add unit tests for FormCalc loops and control flow expressions
tsepez Nov 10, 2026
d340036
Support conservative stack scanning in standalone cppgc heap
tsepez Nov 10, 2026
eb694da
Add unit tests for core/fxcrt/xml parser
tsepez Nov 10, 2026
b07efcd
Use FX_BGRA_STRUCT<uint8_t> spans inside cfx_scanlinecompositor_hwy.cpp
leizleiz Nov 10, 2026
497e33a
Add unit tests for CPVT_FontMap
tsepez Nov 10, 2026
bb85c99
Add unit tests for core/fxcrt/css
tsepez Nov 10, 2026
034c460
Add embedder tests for page box mutators and clip path transform
tsepez Nov 10, 2026
ebffd53
Add unit test for a bug in FlatePredictorScanlineDecoder::Rewind()
leizleiz Nov 11, 2026
0254d29
Properly reset state in FlatePredictorScanlineDecoder::Rewind()
leizleiz Nov 11, 2026
7efd3f3
Add embedder tests for annotation subtype predicates
tsepez Nov 11, 2026
e5e432d
Add JavaScript tests for app methods and field properties
tsepez Nov 11, 2026
7758e6f
Add unit tests for CFX_Barcode methods and edge cases
tsepez Nov 11, 2026
a05cd1c
Remove dead SetFontStyle from CBC_OneCode and CBC_OneDimWriter
tsepez Nov 11, 2026
2686a8c
Revert "Support conservative stack scanning in standalone cppgc heap"
tsepez Nov 11, 2026
833ce83
Ensure equal span sizes inside cfx_scanlinecompositor_hwy.cpp kernels
leizleiz Nov 11, 2026
89660ba
Store annotations as indirect objects in /Annots
cfgnunes Nov 11, 2026
4a9b009
Use std::optional<size_t> for a CXFA_TextLayout::LoaderContext field
leizleiz Nov 11, 2026
a724e52
Separate graph reference counting into tree_traversal_util
tsepez Nov 11, 2026
cc6e71c
Update Highway build config
leizleiz Nov 11, 2026
99da130
Fix nits in tree_traversal_util.h/.cpp.
tsepez Nov 11, 2026
ddb2abb
Add an /ActualText test with RTL glyphs, numbers and punctuation
janwytze Nov 12, 2026
ec80692
Use SetTextSkipNotify in CFWL_ComboBox programmatic updates
tsepez Nov 12, 2026
5a999b6
Add unit test for a bug in FaxDecoder::Rewind()
leizleiz Nov 12, 2026
867e322
Properly reset state in FaxDecoder::Rewind()
leizleiz Nov 12, 2026
4e04b13
Fix float-cast-overflow in CheckSimpleLinePath
a-googler Nov 12, 2026
583f806
Detect cycles using iterative DFS in tree_traversal_util
tsepez Nov 13, 2026
40367e9
Add FPDFTextEmbedderTest.RtlMultiCharGlyph
janwytze Nov 13, 2026
a583450
Accelerate BGRA to mask scanline compositing with SIMD
tycket033-tech Nov 13, 2026
9a0f5b3
Replace UnownedPtr with raw pointers for GCed types in XFA
Nov 13, 2026
982029c
Reject unsupported 192-bit AES keys and clean up per-object derivation
tsepez Nov 13, 2026
e1f3a77
Handle reachable NOTREACHED() in CXFA_TextLayout::InitBreak()
leizleiz Nov 14, 2026
916d6f5
Ensure XFA list wrappers are tracked in binding map
tsepez Nov 14, 2026
1f02bc7
Remove NewBoundV8Object from CFXJSE_HostObject
tsepez Nov 14, 2026
8aaf93f
Sync S18: merge upstream PDFium up to 1f02bc7d90 (Nov 13 2026)
bobsingor Nov 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Bill Denney <wdenney@humanpredictions.com>
Chenguang Shao <chenguangshao1@gmail.com>
Chery Cherian <cherycherian@gmail.com>
Claudio DeSouza <claudiomdsjr@gmail.com>
Cristiano Fraga G. Nunes <cfgnunes@gmail.com>
Dan Ilan <danilan@gmail.com>
Deepak Mohan <hop2deep@gmail.com>
Dmitrii Chunikhin <chunikhindf@gmail.com>
Expand Down
4 changes: 2 additions & 2 deletions DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling depot_tools
# and whatever else without interference from each other.
'depot_tools_revision': 'a03dfbf7f2d1cefa2795d81d59ca4f16c8616a8f',
'depot_tools_revision': '96a7c1418eedaa6bea333a8941e8a0078681b4d0',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling dragonbox
# and whatever else without interference from each other.
Expand Down Expand Up @@ -256,7 +256,7 @@ vars = {
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling tools_memory
# and whatever else without interference from each other.
'tools_memory_revision': '3d4610fc0dd49053c0395bc2825dfc6ac72ab64e',
'tools_memory_revision': 'db1b13009b4ae8a321f7055bcce8e7267ef74729',
# Three lines of non-changing comments so that
# the commit queue can handle CLs rolling tools_rust
# and whatever else without interference from each other.
Expand Down
6 changes: 2 additions & 4 deletions core/fpdfapi/font/cpdf_cmapparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_simple_parser.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/containers/extend.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/to_underlying.h"
Expand Down Expand Up @@ -134,10 +135,7 @@ void CPDF_CMapParser::HandleCodeSpaceRange(ByteStringView word) {
: CPDF_CMap::OneByte);
} else if (nSegs > 1) {
cmap_->SetCodingScheme(CPDF_CMap::MixedFourBytes);
ranges_.reserve(nSegs);
std::move(pending_ranges_.begin(), pending_ranges_.end(),
std::back_inserter(ranges_));
pending_ranges_.clear();
pdfium::Extend(ranges_, std::move(pending_ranges_));
}
status_ = kStart;
}
Expand Down
40 changes: 28 additions & 12 deletions core/fpdfapi/page/cpdf_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/cpdf_string.h"
#include "core/fxcodec/flate/flatemodule.h"
#include "core/fxcodec/fx_codec.h"
#include "core/fxcodec/jpeg/jpegmodule.h"
#include "core/fxcodec/png/pngmodule.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/check_op.h"
#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_2d_size.h"
#include "core/fxcrt/fx_ceil_div.h"
Expand All @@ -42,6 +42,12 @@
#include "core/fxge/dib/cfx_dibitmap.h"
#include "core/fxge/dib/fx_dib.h"

#if defined(PDF_USE_LIBYUV)
#include "core/fxge/fx_libyuv_wrappers.h"
#else
#include "core/fxcrt/zip.h"
#endif

// EmbedPDF(redaction): rewriting an image's stream in place, for
// OverwriteStreamInPlace().
namespace {
Expand Down Expand Up @@ -434,23 +440,33 @@ void CPDF_Image::SetImage(const RetainPtr<CFX_DIBitmap>& pBitmap) {
dest_span = fxcrt::spancpy(dest_span, src_span.first(dest_pitch));
src_span = src_span.subspan(static_cast<size_t>(src_pitch));
}
} else if (bpp == 24) {
for (int32_t row = 0; row < BitmapHeight; row++) {
fxcodec::ReverseRGB(dest_span, src_span, BitmapWidth);
dest_span = dest_span.subspan(dest_pitch);
src_span = src_span.subspan(static_cast<size_t>(src_pitch));
}
} else {
const size_t src_step = bpp == 24 ? 3 : 4;
#if defined(PDF_USE_LIBYUV)
pdfium::ARGBToRAW(src_span, src_pitch, dest_span,
pdfium::checked_cast<int>(dest_pitch), BitmapWidth,
BitmapHeight);
#else
for (int32_t row = 0; row < BitmapHeight; row++) {
uint8_t* dest_ptr = dest_span.data();
const uint8_t* src_ptr = src_span.data();
for (int32_t column = 0; column < BitmapWidth; column++) {
UNSAFE_TODO({
dest_ptr[0] = src_ptr[2];
dest_ptr[1] = src_ptr[1];
dest_ptr[2] = src_ptr[0];
dest_ptr += 3;
src_ptr += src_step;
});
auto src_row =
fxcrt::reinterpret_span<const FX_BGRA_STRUCT<uint8_t>>(src_span)
.first(static_cast<size_t>(BitmapWidth));
auto dest_row =
fxcrt::reinterpret_span<FX_RGB_STRUCT<uint8_t>>(dest_span);
for (auto [input, output] : fxcrt::Zip(src_row, dest_row)) {
output.red = input.red;
output.green = input.green;
output.blue = input.blue;
}
dest_span = dest_span.subspan(dest_pitch);
src_span = src_span.subspan(static_cast<size_t>(src_pitch));
}
#endif
}

stream_ =
Expand Down
3 changes: 3 additions & 0 deletions core/fpdfapi/parser/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ source_set("parser") {
"fpdf_parser_utility.h",
"object_tree_traversal_util.cpp",
"object_tree_traversal_util.h",
"tree_traversal_util.cpp",
"tree_traversal_util.h",
]
configs += [ "../../../:pdfium_strict_config" ]
public_deps = [
Expand Down Expand Up @@ -173,6 +175,7 @@ pdfium_unittest_source_set("unittests") {
"cpdf_syntax_parser_unittest.cpp",
"fpdf_parser_decode_unittest.cpp",
"fpdf_parser_utility_unittest.cpp",
"tree_traversal_util_unittest.cpp",
]
deps = [
":parser",
Expand Down
49 changes: 40 additions & 9 deletions core/fpdfapi/parser/cpdf_crypto_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "core/fxcrt/check.h"
#include "core/fxcrt/check_op.h"
#include "core/fxcrt/epdf_secure_random.h"
#include "core/fxcrt/notreached.h"
#include "core/fxcrt/span_util.h"
#include "core/fxcrt/stl_util.h"

namespace {
Expand All @@ -44,6 +46,36 @@ struct AESCryptContext {

} // namespace

// static
bool CPDF_CryptoHandler::IsValidKeyLength(Cipher cipher, size_t key_len) {
switch (cipher) {
case Cipher::kAES:
return key_len == 16 || key_len == 32;
case Cipher::kAES2:
return key_len == 32;
case Cipher::kRC4:
return key_len >= 5 && key_len <= 16;
case Cipher::kNone:
return true;
}
NOTREACHED();
}

// static
bool CPDF_CryptoHandler::RequiresPerObjectKeyDerivation(Cipher cipher,
size_t key_len) {
switch (cipher) {
case Cipher::kNone:
case Cipher::kAES2:
return false;
case Cipher::kRC4:
return true;
case Cipher::kAES:
return key_len == 16;
}
NOTREACHED();
}

// static
bool CPDF_CryptoHandler::IsSignatureDictionary(
const CPDF_Dictionary* dictionary) {
Expand Down Expand Up @@ -74,7 +106,9 @@ std::optional<DataVector<uint8_t>> CPDF_CryptoHandler::EncryptContent(
}
std::array<uint8_t, 16> realkey;
size_t realkeylen = realkey.size();
if (cipher_ != Cipher::kAES || key_len_ != 32) {
const bool requires_derivation =
RequiresPerObjectKeyDerivation(cipher_, key_len_);
if (requires_derivation) {
std::array<uint8_t, 32> key1;
PopulateKey(objnum, gennum, key1);
if (cipher_ == Cipher::kAES) {
Expand All @@ -86,11 +120,11 @@ std::optional<DataVector<uint8_t>> CPDF_CryptoHandler::EncryptContent(
realkeylen = std::min(key_len_ + 5, realkeylen);
}
if (cipher_ == Cipher::kAES) {
if (key_len_ == 32) {
CRYPT_AESSetKey(aes_context_.get(), encrypt_key_);
} else {
if (requires_derivation) {
CRYPT_AESSetKey(aes_context_.get(),
pdfium::span(realkey).first(key_len_));
} else {
CRYPT_AESSetKey(aes_context_.get(), encrypt_key_);
}

static constexpr size_t kIVSize = 16;
Expand Down Expand Up @@ -134,7 +168,7 @@ void* CPDF_CryptoHandler::DecryptStart(uint32_t objnum, uint32_t gennum) {
AESCryptContext* context = FX_Alloc(AESCryptContext, 1);
context->iv_ = true;
context->block_offset_ = 0;
if (key_len_ == 32) {
if (!RequiresPerObjectKeyDerivation(cipher_, key_len_)) {
CRYPT_AESSetKey(&context->context_, encrypt_key_);
return context;
}
Expand Down Expand Up @@ -340,10 +374,7 @@ bool CPDF_CryptoHandler::DecryptObjectTree(RetainPtr<CPDF_Object> object) {
CPDF_CryptoHandler::CPDF_CryptoHandler(Cipher cipher,
pdfium::span<const uint8_t> key)
: key_len_(std::min<size_t>(key.size(), 32)), cipher_(cipher) {
DCHECK(cipher != Cipher::kAES || key.size() == 16 || key.size() == 24 ||
key.size() == 32);
DCHECK(cipher != Cipher::kAES2 || key.size() == 32);
DCHECK(cipher != Cipher::kRC4 || (key.size() >= 5 && key.size() <= 16));
DCHECK(IsValidKeyLength(cipher, key.size()));

if (cipher_ != Cipher::kNone) {
fxcrt::Copy(key.first(key_len_), encrypt_key_);
Expand Down
2 changes: 2 additions & 0 deletions core/fpdfapi/parser/cpdf_crypto_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class CPDF_CryptoHandler {
kAES2 = 3,
};

static bool IsValidKeyLength(Cipher cipher, size_t key_len);
static bool RequiresPerObjectKeyDerivation(Cipher cipher, size_t key_len);
static bool IsSignatureDictionary(const CPDF_Dictionary* dictionary);

CPDF_CryptoHandler(Cipher cipher, pdfium::span<const uint8_t> key);
Expand Down
16 changes: 1 addition & 15 deletions core/fpdfapi/parser/cpdf_security_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,6 @@ void CalcEncryptKey(const CPDF_Dictionary* pEncrypt,
fxcrt::Copy(digest_span, key);
}

bool IsValidKeyLengthForCipher(CPDF_CryptoHandler::Cipher cipher,
size_t keylen) {
switch (cipher) {
case CPDF_CryptoHandler::Cipher::kAES:
return keylen == 16 || keylen == 24 || keylen == 32;
case CPDF_CryptoHandler::Cipher::kAES2:
return keylen == 32;
case CPDF_CryptoHandler::Cipher::kRC4:
return keylen >= 5 && keylen <= 16;
case CPDF_CryptoHandler::Cipher::kNone:
return true;
}
}

int BigOrder64BitsMod3(pdfium::span<const uint8_t> data) {
uint64_t ret = 0;
for (int i = 0; i < 4; ++i) {
Expand Down Expand Up @@ -326,7 +312,7 @@ static bool LoadCryptInfo(const CPDF_Dictionary* pEncryptDict,
if (keylen < 0 || keylen > 32) {
return false;
}
if (!IsValidKeyLengthForCipher(*cipher, keylen)) {
if (!CPDF_CryptoHandler::IsValidKeyLength(*cipher, keylen)) {
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions core/fpdfapi/parser/cpdf_security_handler_embeddertest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -730,3 +730,7 @@ TEST_F(CPDFSecurityHandlerEmbedderTest, Bug424613308) {
// Test passes if CHECK() does not fail.
ASSERT_FALSE(OpenDocument("bug_424613308.pdf"));
}

TEST_F(CPDFSecurityHandlerEmbedderTest, Bug585348292) {
EXPECT_FALSE(OpenDocument("bug_585348292.pdf"));
}
Loading