0

Send unknown text render modes to the PDF accessibility tree

When the plugin sends a message to the renderer, bounds checking is
performed on all IPC enum traits. Messages containing bad data are
dropped.

Consequently, text runs containing no text need to have their style
initialized to an unknown mode instead of leaving the field
uninitialized. The uninitialized field was trying to pass garbage values
through IPC, causing the entire message to be dropped.

This issue was discovered after crrev.com/830918 was reverted, because
the change depended on accessibility info to be sent sequentially for
every page. A single dropped message would prevent the accessibility
tree from ever finishing.

Bug: 1150665
Change-Id: I0857b79da817e01a9c570d5a9172086ad9f39d67
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2567353
Reviewed-by: Ankit Kumar 🌪️ <ankk@microsoft.com>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Bill Budge <bbudge@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833065}
This commit is contained in:
Daniel Hosseinian
2020-12-03 00:47:09 +00:00
committed by Chromium LUCI CQ
parent dd11d1543e
commit 2b747ef5ce
3 changed files with 7 additions and 2 deletions
pdf/pdfium
ppapi

@ -396,7 +396,8 @@ void PDFiumPage::CalculateTextRunStyleInfo(
}
int render_mode = FPDFText_GetTextRenderMode(text_page, char_index);
if (render_mode < 0 || render_mode > PP_TEXTRENDERINGMODE_LAST) {
if (render_mode < PP_TEXTRENDERINGMODE_FIRST ||
render_mode > PP_TEXTRENDERINGMODE_LAST) {
style_info->render_mode = PP_TEXTRENDERINGMODE_UNKNOWN;
} else {
style_info->render_mode = static_cast<PP_TextRenderingMode>(render_mode);
@ -457,6 +458,7 @@ PDFiumPage::GetTextRunInfo(int start_char_index) {
info.len = chars_count - start_char_index;
info.bounds = pp::FloatRect();
info.direction = PP_PRIVATEDIRECTION_NONE;
info.style.render_mode = PP_TEXTRENDERINGMODE_UNKNOWN;
return info;
}

@ -104,6 +104,7 @@ struct PP_PrivateAccessibilityPageInfo {
// See PDF Reference 1.7, page 402, table 5.3.
typedef enum {
PP_TEXTRENDERINGMODE_UNKNOWN = -1,
PP_TEXTRENDERINGMODE_FIRST = PP_TEXTRENDERINGMODE_UNKNOWN,
PP_TEXTRENDERINGMODE_FILL = 0,
PP_TEXTRENDERINGMODE_STROKE = 1,
PP_TEXTRENDERINGMODE_FILLSTROKE = 2,

@ -131,7 +131,9 @@ IPC_ENUM_TRAITS_MAX_VALUE(PP_VideoFrame_Format, PP_VIDEOFRAME_FORMAT_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(PP_HardwareAcceleration, PP_HARDWAREACCELERATION_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(PP_VideoProfile, PP_VIDEOPROFILE_MAX)
IPC_ENUM_TRAITS_MAX_VALUE(PP_PrivateDirection, PP_PRIVATEDIRECTION_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(PP_TextRenderingMode, PP_TEXTRENDERINGMODE_LAST)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(PP_TextRenderingMode,
PP_TEXTRENDERINGMODE_FIRST,
PP_TEXTRENDERINGMODE_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(PP_PdfAccessibilityAction,
PP_PDF_ACCESSIBILITYACTION_LAST)
IPC_ENUM_TRAITS_MAX_VALUE(PP_PdfAccessibilityScrollAlignment,