From c8c61879f7689b0a047630fcd90846f577847db5 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Mon, 30 Mar 2009 15:23:16 +0000 Subject: [PATCH] Fixed CORE-2359 - Logical multibyte maximum string length is not respected when assigning numbers --- src/common/cvt.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/cvt.cpp b/src/common/cvt.cpp index 1247608265..b00d860fa6 100644 --- a/src/common/cvt.cpp +++ b/src/common/cvt.cpp @@ -379,6 +379,7 @@ static void integer_to_text(const dsc* from, dsc* to, Callbacks* cb) } UCHAR* q = (to->dsc_dtype == dtype_varying) ? to->dsc_address + sizeof(USHORT) : to->dsc_address; + const UCHAR* start = q; /* If negative, put in minus sign */ @@ -389,10 +390,13 @@ static void integer_to_text(const dsc* from, dsc* to, Callbacks* cb) copy number */ if (scale >= 0) + { do { *q++ = *--p; } while (--l); - else { + } + else + { l += scale; /* l > 0 (see postassertion: l+scale > 0 above) */ do { *q++ = *--p; @@ -403,12 +407,16 @@ static void integer_to_text(const dsc* from, dsc* to, Callbacks* cb) } while (++scale); } + cb->validateLength(cb->getToCharset(to->getCharSet()), length, start, TEXT_LEN(to), cb->err); + /* If padding is required, do it now. */ if (pad_count) + { do { *q++ = '0'; } while (--pad_count); + } /* Finish up by padding (if fixed) or computing the actual length (varying string) */