xmloff/source/forms/propertyimport.cxx | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-)
New commits: commit e640d4e47366548ab1f2d938db1d9256ebfdbe70 Author: Caolán McNamara <caolan.mcnam...@collabora.com> AuthorDate: Sun Sep 1 12:34:08 2024 +0100 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Sun Sep 1 16:32:18 2024 +0200 cid#1606637 Overflowed integer argument Change-Id: I83a94ce7bd2d926ca925860cc712ec5ece87ae86 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172720 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/xmloff/source/forms/propertyimport.cxx b/xmloff/source/forms/propertyimport.cxx index 260560d4c5c8..d89ecc71e687 100644 --- a/xmloff/source/forms/propertyimport.cxx +++ b/xmloff/source/forms/propertyimport.cxx @@ -132,21 +132,34 @@ Any PropertyConversion::convertString( const css::uno::Type& _rExpectedType, } break; case TypeClass_SHORT: // sal_Int16 + { + if (!_pEnumMap) + { // it's a real int16 property + sal_Int32 nValue(0); + bool bSuccess = + ::sax::Converter::convertNumber(nValue, _rReadCharacters, SAL_MIN_INT16, SAL_MAX_INT16); + OSL_ENSURE(bSuccess, + OStringBuffer("PropertyConversion::convertString: could not convert \"" + + OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US) + + "\" into a sal_Int16!").getStr()); + aReturn <<= static_cast<sal_Int16>(nValue); + break; + } + aReturn = convertAsEnum(true, _rExpectedType, _rReadCharacters, _pEnumMap); + } + break; case TypeClass_LONG: // sal_Int32 { if (!_pEnumMap) - { // it's a real int32/16 property + { // it's a real int32 property sal_Int32 nValue(0); bool bSuccess = ::sax::Converter::convertNumber(nValue, _rReadCharacters); OSL_ENSURE(bSuccess, OStringBuffer("PropertyConversion::convertString: could not convert \"" + OUStringToOString(_rReadCharacters, RTL_TEXTENCODING_ASCII_US) + - "\" into an integer!").getStr()); - if (TypeClass_SHORT == _rExpectedType.getTypeClass()) - aReturn <<= static_cast<sal_Int16>(nValue); - else - aReturn <<= nValue; + "\" into a sal_Int32!").getStr()); + aReturn <<= nValue; break; } aReturn = convertAsEnum(true, _rExpectedType, _rReadCharacters, _pEnumMap);