office-gobmx/external/icu/ubsan.patch
Stephan Bergmann fdf5bb5001 external/icu: Silence UBSan invalid-null-argument
...as seen during CppunitTest_i18npool_test_ordinalsuffix:

> uloc.cpp:1206:5: runtime error: null pointer passed as argument 1, which is declared to never be null
> /usr/include/string.h:44:28: note: nonnull attribute specified here
>  #0 in ulocimp_getLanguage_67 at workdir/UnpackedTarball/icu/source/common/uloc.cpp:1206:5
>  #1 in uloc_getCountry_67 at workdir/UnpackedTarball/icu/source/common/uloc.cpp:1803:5
>  #2 in ulocimp_getRegionForSupplementalData_67 at workdir/UnpackedTarball/icu/source/common/loclikely.cpp:1334:17
>  #3 in idForLocale(char const*, char*, int, UErrorCode*) at workdir/UnpackedTarball/icu/source/common/ucurr.cpp:350:5
>  #4 in ucurr_forLocale_67 at workdir/UnpackedTarball/icu/source/common/ucurr.cpp:535:5
>  #5 in icu_67::DecimalFormatSymbols::initialize(icu_67::Locale const&, UErrorCode&, signed char, icu_67::NumberingSystem const*) at workdir/UnpackedTarball/icu/source/i18n/dcfmtsym.cpp:461:29
>  #6 in icu_67::DecimalFormatSymbols::DecimalFormatSymbols(icu_67::Locale const&, UErrorCode&) at workdir/UnpackedTarball/icu/source/i18n/dcfmtsym.cpp:110:5
>  #7 in icu_67::RuleBasedNumberFormat::initializeDecimalFormatSymbols(UErrorCode&) at workdir/UnpackedTarball/icu/source/i18n/rbnf.cpp:1854:53
>  #8 in icu_67::RuleBasedNumberFormat::init(icu_67::UnicodeString const&, icu_67::LocalizationInfo*, UParseError&, UErrorCode&) at workdir/UnpackedTarball/icu/source/i18n/rbnf.cpp:1488:5
>  #9 in icu_67::RuleBasedNumberFormat::RuleBasedNumberFormat(icu_67::URBNFRuleSetTag, icu_67::Locale const&, UErrorCode&) at workdir/UnpackedTarball/icu/source/i18n/rbnf.cpp:867:9
>  #10 in i18npool::OrdinalSuffixService::getOrdinalSuffix(int, com::sun::lang::Locale const&) at i18npool/source/ordinalsuffix/ordinalsuffix.cxx:79:32
>  #11 in non-virtual thunk to i18npool::OrdinalSuffixService::getOrdinalSuffix(int, com::sun::lang::Locale const&) at i18npool/source/ordinalsuffix/ordinalsuffix.cxx
>  #12 in TestOrdinalSuffix::testFrench() at i18npool/qa/cppunit/test_ordinalsuffix.cxx:53:29

etc.

Change-Id: I4a87ee36fd33791c3906d6b6adc72ec824c4b3ae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94047
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-05-12 16:37:47 +02:00

52 lines
1.5 KiB
Diff

--- source/common/uloc.cpp
+++ source/common/uloc.cpp
@@ -1203,7 +1203,8 @@
return 0;
}
int32_t reslen = result.length();
- uprv_memcpy(language, result.data(), std::min(reslen, languageCapacity));
+ auto const n = std::min(reslen, languageCapacity);
+ if (n != 0) uprv_memcpy(language, result.data(), n);
return reslen;
}
@@ -1251,7 +1252,8 @@
return 0;
}
int32_t reslen = result.length();
- uprv_memcpy(script, result.data(), std::min(reslen, scriptCapacity));
+ auto const n = std::min(reslen, scriptCapacity);
+ if (n != 0) uprv_memcpy(script, result.data(), n);
return reslen;
}
--- source/tools/genrb/rbutil.c
+++ source/tools/genrb/rbutil.c
@@ -30,7 +30,12 @@
get_dirname(char *dirname,
const char *filename)
{
- const char *lastSlash = uprv_strrchr(filename, U_FILE_SEP_CHAR) + 1;
+ const char *lastSlash = uprv_strrchr(filename, U_FILE_SEP_CHAR);
+ if(lastSlash == NULL) {
+ lastSlash = filename;
+ } else {
+ ++lastSlash;
+ }
if(lastSlash>filename) {
uprv_strncpy(dirname, filename, (lastSlash - filename));
@@ -46,7 +51,12 @@
const char *filename)
{
/* strip off any leading directory portions */
- const char *lastSlash = uprv_strrchr(filename, U_FILE_SEP_CHAR) + 1;
+ const char *lastSlash = uprv_strrchr(filename, U_FILE_SEP_CHAR);
+ if(lastSlash == NULL) {
+ lastSlash = filename;
+ } else {
+ ++lastSlash;
+ }
char *lastDot;
if(lastSlash>filename) {