oss-fuzz/projects/dlplibs/icu4c-ubsan.patch

92 lines
4.7 KiB
Diff

diff -ur icu.org/source/common/rbbidata.h icu/source/common/rbbidata.h
--- icu.org/source/common/rbbidata.h 2017-02-03 19:57:23.000000000 +0100
+++ icu/source/common/rbbidata.h 2017-04-21 22:46:25.371651160 +0200
@@ -115,7 +115,7 @@
/* StatusTable of the set of matching */
/* tags (rule status values) */
int16_t fReserved;
- uint16_t fNextState[2]; /* Next State, indexed by char category. */
+ uint16_t fNextState[1]; /* Next State, indexed by char category. */
/* This array does not have two elements */
/* Array Size is actually fData->fHeader->fCatCount */
/* CAUTION: see RBBITableBuilder::getTableSize() */
@@ -128,7 +128,7 @@
uint32_t fRowLen; /* Length of a state table row, in bytes. */
uint32_t fFlags; /* Option Flags for this state table */
uint32_t fReserved; /* reserved */
- char fTableData[4]; /* First RBBIStateTableRow begins here. */
+ char fTableData[1]; /* First RBBIStateTableRow begins here. */
/* (making it char[] simplifies ugly address */
/* arithmetic for indexing variable length rows.) */
};
diff -ur icu.org/source/common/rbbitblb.cpp icu/source/common/rbbitblb.cpp
--- icu.org/source/common/rbbitblb.cpp 2017-01-20 01:20:31.000000000 +0100
+++ icu/source/common/rbbitblb.cpp 2017-04-21 22:46:25.373651159 +0200
@@ -1095,15 +1095,15 @@
return 0;
}
- size = sizeof(RBBIStateTable) - 4; // The header, with no rows to the table.
+ size = offsetof(RBBIStateTable, fTableData); // The header, with no rows to the table.
numRows = fDStates->size();
numCols = fRB->fSetBuilder->getNumCharCategories();
- // Note The declaration of RBBIStateTableRow is for a table of two columns.
- // Therefore we subtract two from numCols when determining
+ // Note The declaration of RBBIStateTableRow is for a table of one columns.
+ // Therefore we subtract one from numCols when determining
// how much storage to add to a row for the total columns.
- rowSize = sizeof(RBBIStateTableRow) + sizeof(uint16_t)*(numCols-2);
+ rowSize = sizeof(RBBIStateTableRow) + sizeof(uint16_t)*(numCols-1);
size += numRows * rowSize;
return size;
}
@@ -1133,7 +1133,7 @@
}
table->fRowLen = sizeof(RBBIStateTableRow) +
- sizeof(uint16_t) * (fRB->fSetBuilder->getNumCharCategories() - 2);
+ sizeof(uint16_t) * (fRB->fSetBuilder->getNumCharCategories() - 1);
table->fNumStates = fDStates->size();
table->fFlags = 0;
if (fRB->fLookAheadHardBreak) {
diff -ur icu.org/source/common/ubidiimp.h icu/source/common/ubidiimp.h
--- icu.org/source/common/ubidiimp.h 2017-02-03 19:57:23.000000000 +0100
+++ icu/source/common/ubidiimp.h 2017-04-21 22:46:25.374651159 +0200
@@ -198,8 +198,8 @@
/* in a Run, logicalStart will get this bit set if the run level is odd */
#define INDEX_ODD_BIT (1UL<<31)
-#define MAKE_INDEX_ODD_PAIR(index, level) ((index)|((int32_t)(level)<<31))
-#define ADD_ODD_BIT_FROM_LEVEL(x, level) ((x)|=((int32_t)(level)<<31))
+#define MAKE_INDEX_ODD_PAIR(index, level) ((index)|((uint32_t)(level)<<31))
+#define ADD_ODD_BIT_FROM_LEVEL(x, level) ((x)|=((uint32_t)(level)<<31))
#define REMOVE_ODD_BIT(x) ((x)&=~INDEX_ODD_BIT)
#define GET_INDEX(x) ((x)&~INDEX_ODD_BIT)
diff -ur icu.org/source/common/ucmndata.cpp icu/source/common/ucmndata.cpp
--- icu.org/source/common/ucmndata.cpp 2017-03-08 16:34:47.000000000 +0100
+++ icu/source/common/ucmndata.cpp 2017-04-21 22:46:25.376651159 +0200
@@ -77,7 +77,7 @@
typedef struct {
uint32_t count;
uint32_t reserved;
- PointerTOCEntry entry[2]; /* Actual size is from count. */
+ PointerTOCEntry entry[1]; /* Actual size is from count. */
} PointerTOC;
diff -ur icu.org/source/common/ucmndata.h icu/source/common/ucmndata.h
--- icu.org/source/common/ucmndata.h 2017-01-20 01:20:31.000000000 +0100
+++ icu/source/common/ucmndata.h 2017-04-21 22:46:25.377651159 +0200
@@ -52,7 +52,7 @@
typedef struct {
uint32_t count;
- UDataOffsetTOCEntry entry[2]; /* Actual size of array is from count. */
+ UDataOffsetTOCEntry entry[1]; /* Actual size of array is from count. */
} UDataOffsetTOC;
/**