office-gobmx/external/icu/ubsan.patch

53 lines
1.5 KiB
Diff
Raw Normal View History

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::star::lang::Locale const&) at i18npool/source/ordinalsuffix/ordinalsuffix.cxx:79:32 > #11 in non-virtual thunk to i18npool::OrdinalSuffixService::getOrdinalSuffix(int, com::sun::star::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 05:11:59 -05:00
--- 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;
}
external/icu: Fix UBSan nullptr-with-nonzero-offset ...(new with Clang 10 trunk), as seen during ExternalProject_icu: > rbutil.c:49:67: runtime error: applying non-zero offset 1 to null pointer > #0 in get_basename at workdir/UnpackedTarball/icu/source/tools/genrb/rbutil.c:49:67 > #1 in make_res_filename(char const*, char const*, char const*, UErrorCode&) at workdir/UnpackedTarball/icu/source/tools/genrb/genrb.cpp:768:5 > #2 in processFile(char const*, char const*, char const*, char const*, char const*, SRBRoot*, signed char, UErrorCode&) at workdir/UnpackedTarball/icu/source/tools/genrb/genrb.cpp:695:14 > #3 in main at workdir/UnpackedTarball/icu/source/tools/genrb/genrb.cpp:527:9 > rbutil.c:54:67: runtime error: applying non-zero offset 1 to null pointer > #0 in get_basename at workdir/UnpackedTarball/icu/source/tools/genrb/rbutil.c:54:67 > #1 in make_res_filename(char const*, char const*, char const*, UErrorCode&) at workdir/UnpackedTarball/icu/source/tools/genrb/genrb.cpp:768:5 > #2 in processFile(char const*, char const*, char const*, char const*, char const*, SRBRoot*, signed char, UErrorCode&) at workdir/UnpackedTarball/icu/source/tools/genrb/genrb.cpp:695:14 > #3 in main at workdir/UnpackedTarball/icu/source/tools/genrb/genrb.cpp:527:9 (uprv_strrchr appears to be plain strrchr, see workdir/UnpackedTarball/icu/source/common/cstring.h, so returns null for "not found", and in both of the fixed places, the following if(lastSlash>filename) was apparently meant to filter out cases where uprv_strrchr returned null.) Change-Id: I32b3a72955d33d73fa4295cf5f91a69fd270efeb Reviewed-on: https://gerrit.libreoffice.org/81613 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-10-28 10:43:23 -05:00
--- 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) {