mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-06 14:05:32 +00:00
ICU-2235 fix length calculations
X-SVN-Rev: 12810
This commit is contained in:
parent
5709fddab7
commit
5b631a7f3b
2 changed files with 9 additions and 2 deletions
|
@ -1158,7 +1158,7 @@ ucnv_swapAliases(const UDataSwapper *ds,
|
|||
}
|
||||
|
||||
/* an alias table must contain at least the table of contents array */
|
||||
if(length>=0 && length<4*(1+minTocLength)) {
|
||||
if(length>=0 && (length-headerSize)<4*(1+minTocLength)) {
|
||||
udata_printError(ds, "ucnv_swapAliases(): too few bytes (%d after header) for an alias table\n",
|
||||
length-headerSize);
|
||||
*pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR;
|
||||
|
@ -1194,6 +1194,13 @@ ucnv_swapAliases(const UDataSwapper *ds,
|
|||
uint16_t *q, *q2;
|
||||
uint16_t oldIndex;
|
||||
|
||||
if((length-headerSize)<(2*(int32_t)topOffset)) {
|
||||
udata_printError(ds, "ucnv_swapAliases(): too few bytes (%d after header) for an alias table\n",
|
||||
length-headerSize);
|
||||
*pErrorCode=U_INDEX_OUTOFBOUNDS_ERROR;
|
||||
return 0;
|
||||
}
|
||||
|
||||
outTable=(uint16_t *)((char *)outData+headerSize);
|
||||
|
||||
/* swap the entire table of contents */
|
||||
|
|
|
@ -154,7 +154,7 @@ struct UDataSwapper;
|
|||
typedef struct UDataSwapper UDataSwapper;
|
||||
|
||||
/**
|
||||
* Swap an ICU converter alias table. See ucnv_io.h.
|
||||
* Swap an ICU converter alias table. See ucnv_io.c.
|
||||
* @internal
|
||||
*/
|
||||
U_CAPI int32_t U_EXPORT2
|
||||
|
|
Loading…
Add table
Reference in a new issue