From ecd36468b5639873295859f29b185c517476cb45 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Tue, 18 Apr 2017 13:12:41 -0400 Subject: Check char sign in fx_ext.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The std methods assume that the input can be represented as unsigned char. Bug: pdfium:703 Change-Id: I11d20869502aff0ebb8badca853398a7d0232338 Reviewed-on: https://pdfium-review.googlesource.com/4171 Commit-Queue: Nicolás Peña Reviewed-by: Tom Sepez --- core/fxcrt/fx_ext.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/fxcrt/fx_ext.h b/core/fxcrt/fx_ext.h index d7f21af9ff..8224087d88 100644 --- a/core/fxcrt/fx_ext.h +++ b/core/fxcrt/fx_ext.h @@ -57,15 +57,19 @@ inline bool FXSYS_iswspace(wchar_t c) { return (c == 0x20) || (c == 0x0d) || (c == 0x0a) || (c == 0x09); } +inline bool FXSYS_isHexDigit(const char c) { + return !((c & 0x80) || !std::isxdigit(c)); +} + inline int FXSYS_toHexDigit(const char c) { - if (!std::isxdigit(c)) + if (!FXSYS_isHexDigit(c)) return 0; char upchar = std::toupper(c); return upchar > '9' ? upchar - 'A' + 10 : upchar - '0'; } inline bool FXSYS_isDecimalDigit(const char c) { - return !!std::isdigit(c); + return !((c & 0x80) || !std::isdigit(c)); } inline bool FXSYS_isDecimalDigit(const wchar_t c) { @@ -73,7 +77,7 @@ inline bool FXSYS_isDecimalDigit(const wchar_t c) { } inline int FXSYS_toDecimalDigit(const char c) { - return std::isdigit(c) ? c - '0' : 0; + return FXSYS_isDecimalDigit(c) ? c - '0' : 0; } inline int FXSYS_toDecimalDigit(const wchar_t c) { -- cgit v1.2.3