diff options
author | Oliver Chang <ochang@chromium.org> | 2016-02-19 15:23:30 -0800 |
---|---|---|
committer | Oliver Chang <ochang@chromium.org> | 2016-02-19 15:23:30 -0800 |
commit | f348235cce75d378a17f3aee81a97f92049fa0a8 (patch) | |
tree | 5f68077ac56d23042833ac70e840083d20bb6c6c /xfa/src/fxfa | |
parent | ae85f87266abee649fe8f202515bba4590196711 (diff) | |
download | pdfium-f348235cce75d378a17f3aee81a97f92049fa0a8.tar.xz |
Add a proper bounds check to XFA_FM_KeywordToString
R=tsepez@chromium.org
BUG=588200
Review URL: https://codereview.chromium.org/1718453003 .
Diffstat (limited to 'xfa/src/fxfa')
-rw-r--r-- | xfa/src/fxfa/src/fm2js/xfa_lexer.cpp | 10 | ||||
-rw-r--r-- | xfa/src/fxfa/src/fm2js/xfa_lexer.h | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/xfa/src/fxfa/src/fm2js/xfa_lexer.cpp b/xfa/src/fxfa/src/fm2js/xfa_lexer.cpp index 957c21b874..2902f8c70b 100644 --- a/xfa/src/fxfa/src/fm2js/xfa_lexer.cpp +++ b/xfa/src/fxfa/src/fm2js/xfa_lexer.cpp @@ -83,7 +83,7 @@ inline FX_BOOL XFA_FMDChar::isUnicodeAlpha(uint16_t ch) { return TRUE; } -XFA_FMKeyword keyWords[] = { +const XFA_FMKeyword keyWords[] = { {TOKand, 0x00000026, L"&"}, {TOKlparen, 0x00000028, L"("}, {TOKrparen, 0x00000029, L")"}, @@ -145,13 +145,15 @@ XFA_FMKeyword keyWords[] = { {TOKendif, 0xe0e8fee6, L"endif"}, }; -const FX_WORD KEYWORD_START = TOKdo; -const FX_WORD KEYWORD_END = TOKendif; +const XFA_FM_TOKEN KEYWORD_START = TOKdo; +const XFA_FM_TOKEN KEYWORD_END = TOKendif; } // namespace const FX_WCHAR* XFA_FM_KeywordToString(XFA_FM_TOKEN op) { - return keyWords[op].m_keword; + if (op < KEYWORD_START || op > KEYWORD_END) + return L""; + return keyWords[op].m_keyword; } CXFA_FMToken::CXFA_FMToken() : m_type(TOKreserver), m_uLinenum(1) {} diff --git a/xfa/src/fxfa/src/fm2js/xfa_lexer.h b/xfa/src/fxfa/src/fm2js/xfa_lexer.h index 5db3b093cd..ccfa9f546e 100644 --- a/xfa/src/fxfa/src/fm2js/xfa_lexer.h +++ b/xfa/src/fxfa/src/fm2js/xfa_lexer.h @@ -83,7 +83,7 @@ enum XFA_FM_TOKEN { struct XFA_FMKeyword { XFA_FM_TOKEN m_type; uint32_t m_uHash; - const FX_WCHAR* m_keword; + const FX_WCHAR* m_keyword; }; const FX_WCHAR* XFA_FM_KeywordToString(XFA_FM_TOKEN op); |