summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-03-21 22:50:15 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-03-22 09:00:57 +0000
commit7778d9f51bd1f4d086cafe95995406c3157afb89 (patch)
tree9a43660947b78d9f714c45e1be48ef46dd0d082e /tools
parent02bccbe0d59e50a7fd987c81c4d15b2fd4d24538 (diff)
Prevent calls to rtl/character.hxx functions with (signed) char arguments
...that would implicitly be sign extended (for plain char only if it is signed), so non-ASCII char values would trigger the isUnicodeCodePoint assert. Change-Id: Iaf8024ad509e64525558e882fe3fd078cfb4ea91 Reviewed-on: https://gerrit.libreoffice.org/35523 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/inet/inetmime.cxx12
-rw-r--r--tools/source/inet/inetmsg.cxx12
-rw-r--r--tools/source/ref/globname.cxx8
3 files changed, 21 insertions, 11 deletions
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index ad15355f19de..27f120a360df 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -892,7 +892,9 @@ bool equalIgnoreCase(const sal_Char * pBegin1,
while (*pString2 != 0)
if (pBegin1 == pEnd1
- || rtl::toAsciiUpperCase(*pBegin1++) != rtl::toAsciiUpperCase(*pString2++))
+ || (rtl::toAsciiUpperCase(static_cast<unsigned char>(*pBegin1++))
+ != rtl::toAsciiUpperCase(
+ static_cast<unsigned char>(*pString2++))))
return false;
return pBegin1 == pEnd1;
}
@@ -1154,7 +1156,9 @@ bool INetMIME::equalIgnoreCase(const sal_Unicode * pBegin1,
while (*pString2 != 0)
if (pBegin1 == pEnd1
- || rtl::toAsciiUpperCase(*pBegin1++) != rtl::toAsciiUpperCase(*pString2++))
+ || (rtl::toAsciiUpperCase(*pBegin1++)
+ != rtl::toAsciiUpperCase(
+ static_cast<unsigned char>(*pString2++))))
return false;
return pBegin1 == pEnd1;
}
@@ -1317,7 +1321,9 @@ OUString INetMIME::decodeHeaderFieldBody(const OString& rBody)
default:
if (pLanguageBegin != nullptr
- && (!rtl::isAsciiAlpha(cChar) || ++nAlphaCount > 8))
+ && (!rtl::isAsciiAlpha(
+ static_cast<unsigned char>(cChar))
+ || ++nAlphaCount > 8))
pLanguageBegin = nullptr;
break;
}
diff --git a/tools/source/inet/inetmsg.cxx b/tools/source/inet/inetmsg.cxx
index 5dec8ff21142..704c44fad587 100644
--- a/tools/source/inet/inetmsg.cxx
+++ b/tools/source/inet/inetmsg.cxx
@@ -57,7 +57,9 @@ static const sal_Char *months[12] =
static sal_uInt16 ParseNumber(const OString& rStr, sal_Int32& nIndex)
{
sal_Int32 n = nIndex;
- while ((n < rStr.getLength()) && rtl::isAsciiDigit(rStr[n])) n++;
+ while ((n < rStr.getLength())
+ && rtl::isAsciiDigit(static_cast<unsigned char>(rStr[n])))
+ n++;
OString aNum(rStr.copy(nIndex, (n - nIndex)));
nIndex = n;
@@ -68,7 +70,9 @@ static sal_uInt16 ParseNumber(const OString& rStr, sal_Int32& nIndex)
static sal_uInt16 ParseMonth(const OString& rStr, sal_Int32& nIndex)
{
sal_Int32 n = nIndex;
- while ((n < rStr.getLength()) && rtl::isAsciiAlpha(rStr[n])) n++;
+ while ((n < rStr.getLength())
+ && rtl::isAsciiAlpha(static_cast<unsigned char>(rStr[n])))
+ n++;
OString aMonth(rStr.copy(nIndex, 3));
nIndex = n;
@@ -99,7 +103,7 @@ bool INetMIMEMessage::ParseDateField (
while (
(nIndex < aDateField.getLength()) &&
- (rtl::isAsciiAlpha (aDateField[nIndex]) ||
+ (rtl::isAsciiAlpha (static_cast<unsigned char>(aDateField[nIndex])) ||
(aDateField[nIndex] == ',') ))
nIndex++;
@@ -107,7 +111,7 @@ bool INetMIMEMessage::ParseDateField (
(aDateField[nIndex] == ' '))
nIndex++;
- if (rtl::isAsciiAlpha (aDateField[nIndex]))
+ if (rtl::isAsciiAlpha (static_cast<unsigned char>(aDateField[nIndex])))
{
// Format: ctime().
if ((aDateField.getLength() - nIndex) < 20) return false;
diff --git a/tools/source/ref/globname.cxx b/tools/source/ref/globname.cxx
index 67bbf7e153be..d6395b79a33a 100644
--- a/tools/source/ref/globname.cxx
+++ b/tools/source/ref/globname.cxx
@@ -188,7 +188,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
if( isdigit( *pStr ) )
nFirst = nFirst * 16 + (*pStr - '0');
else
- nFirst = nFirst * 16 + (rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 );
+ nFirst = nFirst * 16 + (rtl::toAsciiUpperCase( static_cast<unsigned char>(*pStr) ) - 'A' + 10 );
else
return false;
pStr++;
@@ -202,7 +202,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
if( isdigit( *pStr ) )
nSec = nSec * 16 + (*pStr - '0');
else
- nSec = nSec * 16 + (sal_uInt16)(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 );
+ nSec = nSec * 16 + (sal_uInt16)(rtl::toAsciiUpperCase( static_cast<unsigned char>(*pStr) ) - 'A' + 10 );
else
return false;
pStr++;
@@ -216,7 +216,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
if( isdigit( *pStr ) )
nThird = nThird * 16 + (*pStr - '0');
else
- nThird = nThird * 16 + (sal_uInt16)(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 );
+ nThird = nThird * 16 + (sal_uInt16)(rtl::toAsciiUpperCase( static_cast<unsigned char>(*pStr) ) - 'A' + 10 );
else
return false;
pStr++;
@@ -231,7 +231,7 @@ bool SvGlobalName::MakeId( const OUString & rIdStr )
if( isdigit( *pStr ) )
szRemain[i/2] = szRemain[i/2] * 16 + (*pStr - '0');
else
- szRemain[i/2] = szRemain[i/2] * 16 + (sal_Int8)(rtl::toAsciiUpperCase( *pStr ) - 'A' + 10 );
+ szRemain[i/2] = szRemain[i/2] * 16 + (sal_Int8)(rtl::toAsciiUpperCase( static_cast<unsigned char>(*pStr) ) - 'A' + 10 );
else
return false;
pStr++;