summaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-10-28 16:43:23 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-10-29 07:42:31 +0100
commit78fbbc77d0e3318c6490470f8050a5b1e3cae28d (patch)
treea32ee9a3266e8ffa06008cc9a3dce9b2cafb1361 /external
parent13532e63e715ab2bfd1a8040bec6f700fbfa6250 (diff)
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>
Diffstat (limited to 'external')
-rw-r--r--external/icu/UnpackedTarball_icu.mk1
-rw-r--r--external/icu/ubsan.patch30
2 files changed, 31 insertions, 0 deletions
diff --git a/external/icu/UnpackedTarball_icu.mk b/external/icu/UnpackedTarball_icu.mk
index 4e23ba2686be..388b7305bc2d 100644
--- a/external/icu/UnpackedTarball_icu.mk
+++ b/external/icu/UnpackedTarball_icu.mk
@@ -43,6 +43,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,icu,\
external/icu/char8_t.patch \
external/icu/c++20-comparison.patch \
external/icu/icu4c-64-54558d1dd01b29c763ca12b6327108fe3ac66637.patch.2 \
+ external/icu/ubsan.patch \
))
$(eval $(call gb_UnpackedTarball_add_file,icu,source/data/brkitr/khmerdict.dict,external/icu/khmerdict.dict))
diff --git a/external/icu/ubsan.patch b/external/icu/ubsan.patch
new file mode 100644
index 000000000000..9acae66465d4
--- /dev/null
+++ b/external/icu/ubsan.patch
@@ -0,0 +1,30 @@
+--- 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) {