From 16d67c3ebb5c92f26a84bbdca1ecbed2189c7899 Mon Sep 17 00:00:00 2001 From: George Rhoten Date: Mon, 28 Aug 2000 19:18:02 +0000 Subject: [PATCH] ICU-463 Put fix for pointer overflow back into code. X-SVN-Rev: 2360 --- icu4c/source/common/unicode/unistr.h | 3 ++- icu4c/source/common/unistr.cpp | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/icu4c/source/common/unicode/unistr.h b/icu4c/source/common/unicode/unistr.h index 269eb9ef48..fc8d970f27 100644 --- a/icu4c/source/common/unicode/unistr.h +++ b/icu4c/source/common/unicode/unistr.h @@ -2571,7 +2571,8 @@ UnicodeString::extract(UTextOffset start, int32_t length, char *dst, const char *codepage) const -{return extract(start, length, dst, INT32_MAX, codepage);} +// This dstSize value should prevent pointer overflow +{return extract(start, length, dst, 0x0FFFFFFF, codepage);} inline void UnicodeString::extractBetween(UTextOffset start, diff --git a/icu4c/source/common/unistr.cpp b/icu4c/source/common/unistr.cpp index 9c5d578734..d254c9e13c 100644 --- a/icu4c/source/common/unistr.cpp +++ b/icu4c/source/common/unistr.cpp @@ -1251,10 +1251,9 @@ UnicodeString::extract(UTextOffset start, /* Pin the limit to U_MAX_PTR. NULL check is for AS/400. */ - /* [grhoten] What sort of silly assumption is this? */ -/* if((myTargetLimit < myTarget) || (myTargetLimit == NULL)) { + if((myTargetLimit < myTarget) || (myTargetLimit == NULL)) { myTargetLimit = (char*)U_MAX_PTR; - }*/ + } if (myTarget != NULL) { ucnv_fromUnicode(converter, &myTarget, myTargetLimit,