mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 04:03:03 +01:00
Fixed CORE-5277 - Parameters with multibyte character sets allow to bypass the character limit of varchar fields.
This commit is contained in:
parent
620cf67fc0
commit
9fede1eb64
@ -795,6 +795,7 @@ void EXE_send(thread_db* tdbb, jrd_req* request, USHORT msg, ULONG length, const
|
||||
{
|
||||
const UCHAR* p = request->getImpure<UCHAR>(message->impureOffset +
|
||||
(ULONG)(IPTR) desc->dsc_address);
|
||||
USHORT descLen = desc->dsc_length;
|
||||
USHORT len;
|
||||
|
||||
switch (desc->dsc_dtype)
|
||||
@ -804,6 +805,7 @@ void EXE_send(thread_db* tdbb, jrd_req* request, USHORT msg, ULONG length, const
|
||||
break;
|
||||
|
||||
case dtype_varying:
|
||||
descLen -= sizeof(USHORT);
|
||||
len = reinterpret_cast<const vary*>(p)->vary_length;
|
||||
p += sizeof(USHORT);
|
||||
break;
|
||||
@ -811,6 +813,17 @@ void EXE_send(thread_db* tdbb, jrd_req* request, USHORT msg, ULONG length, const
|
||||
|
||||
CharSet* charSet = INTL_charset_lookup(tdbb, DSC_GET_CHARSET(desc));
|
||||
|
||||
const USHORT srcCharLen = charSet->length(len, p, false);
|
||||
const USHORT dstCharLen = descLen / charSet->maxBytesPerChar();
|
||||
|
||||
if (srcCharLen > dstCharLen)
|
||||
{
|
||||
status_exception::raise(
|
||||
Arg::Gds(isc_arith_except) <<
|
||||
Arg::Gds(isc_string_truncation) <<
|
||||
Arg::Gds(isc_trunc_limits) << Arg::Num(dstCharLen) << Arg::Num(srcCharLen));
|
||||
}
|
||||
|
||||
if (!charSet->wellFormed(len, p))
|
||||
ERR_post(Arg::Gds(isc_malformed_string));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user