From ba8166521cfd57ec65151c91979ed3696a40f700 Mon Sep 17 00:00:00 2001 From: asfernandes Date: Sun, 1 Nov 2009 17:00:20 +0000 Subject: [PATCH] Backport fix for CORE-2722 - Storage of malformed blob is allowed when copying from a blob with NONE/OCTETS charset --- src/jrd/blb.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/jrd/blb.cpp b/src/jrd/blb.cpp index 69ca0e6503..1fe88e7667 100644 --- a/src/jrd/blb.cpp +++ b/src/jrd/blb.cpp @@ -1003,16 +1003,20 @@ void BLB_move(thread_db* tdbb, dsc* from_desc, dsc* to_desc, jrd_nod* field) if (*source == *destination) return; + UCHAR fromCharSet = from_desc->getCharSet(); + UCHAR toCharSet = to_desc->getCharSet(); + const bool needFilter = (from_desc->dsc_sub_type != isc_blob_untyped && to_desc->dsc_sub_type != isc_blob_untyped && (from_desc->dsc_sub_type != to_desc->dsc_sub_type || (from_desc->dsc_sub_type == isc_blob_text && - from_desc->dsc_scale != to_desc->dsc_scale && - to_desc->dsc_scale != CS_NONE && to_desc->dsc_scale != CS_BINARY))); + fromCharSet != toCharSet && + toCharSet != CS_NONE && toCharSet != CS_BINARY && + fromCharSet != CS_NONE && fromCharSet != CS_BINARY))); if (!needFilter && to_desc->isBlob() && - (from_desc->getCharSet() == CS_NONE || from_desc->getCharSet() == CS_BINARY) && - (to_desc->getCharSet() != CS_NONE && to_desc->getCharSet() != CS_BINARY)) + (fromCharSet == CS_NONE || fromCharSet == CS_BINARY) && + (toCharSet != CS_NONE && toCharSet != CS_BINARY)) { AutoBlb blob(tdbb, BLB_open(tdbb, tdbb->getTransaction(), source)); BLB_check_well_formed(tdbb, to_desc, blob.getBlb());