8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 01:23:03 +01:00

Backported fix for CORE-5673: Unique constraint not working in encrypted database on first command

This commit is contained in:
AlexPeshkoff 2017-11-29 11:34:22 +03:00
parent 355c6f4f1c
commit 992554a63f
3 changed files with 49 additions and 8 deletions

View File

@ -1054,10 +1054,14 @@ namespace Jrd {
return FAILED_CRYPT;
}
cryptPlugin->decrypt(sv, dbb.dbb_page_size - sizeof(Ods::pag),
FbLocalStatus ls;
cryptPlugin->decrypt(&ls, dbb.dbb_page_size - sizeof(Ods::pag),
&page[1], &page[1]);
if (sv->getState() & IStatus::STATE_ERRORS)
if (ls->getState() & IStatus::STATE_ERRORS)
{
ERR_post_nothrow(&ls, sv);
return FAILED_CRYPT;
}
}
return SUCCESS_ALL;
@ -1139,11 +1143,15 @@ namespace Jrd {
return FAILED_CRYPT;
}
FbLocalStatus ls;
to[0] = page[0];
cryptPlugin->encrypt(sv, dbb.dbb_page_size - sizeof(Ods::pag),
cryptPlugin->encrypt(&ls, dbb.dbb_page_size - sizeof(Ods::pag),
&page[1], &to[1]);
if (sv->getState() & IStatus::STATE_ERRORS)
if (ls->getState() & IStatus::STATE_ERRORS)
{
ERR_post_nothrow(&ls, sv);
return FAILED_CRYPT;
}
to->pag_flags |= Ods::crypted_page; // Mark page that is going to be written as encrypted
page->pag_flags |= Ods::crypted_page; // Set the mark for page in cache as well

View File

@ -55,6 +55,7 @@ using namespace Firebird;
static void internal_error(ISC_STATUS status, int number, const TEXT* file = NULL, int line = 0);
static void post_nothrow(const unsigned lenToAdd, const ISC_STATUS* toAdd, FbStatusVector* statusVector);
void ERR_bugcheck(int number, const TEXT* file, int line)
@ -207,14 +208,45 @@ void ERR_post_nothrow(const Arg::StatusVector& v, FbStatusVector* statusVector)
*
**************************************/
{
// calculate length of the status
unsigned lenToAdd = v.length();
post_nothrow(v.length(), v.value(), statusVector);
}
void ERR_post_nothrow(const IStatus* v, FbStatusVector* statusVector)
/**************************************
*
* E R R _ p o s t _ n o t h r o w
*
**************************************
*
* Functional description
* Populate a status vector.
*
**************************************/
{
const ISC_STATUS* toAdd = v->getErrors();
post_nothrow(fb_utils::statusLength(toAdd), toAdd, statusVector);
}
static void post_nothrow(const unsigned lenToAdd, const ISC_STATUS* toAdd, FbStatusVector* statusVector)
/**************************************
*
* E R R _ p o s t _ n o t h r o w
*
**************************************
*
* Functional description
* Populate a status vector.
*
**************************************/
{
// check status to add
if (lenToAdd == 0) // nothing to do
return;
const ISC_STATUS* toAdd = v.value();
fb_assert(toAdd[0] == isc_arg_gds);
// Use default from tdbb when no vector specified
// use default from tdbb when no vector specified
if (!statusVector)
statusVector = JRD_get_thread_data()->tdbb_status_vector;

View File

@ -54,6 +54,7 @@ void ERR_corrupt(int);
void ERR_error(int);
void ERR_post(const Firebird::Arg::StatusVector& v);
void ERR_post_nothrow(const Firebird::Arg::StatusVector& v, Jrd::FbStatusVector* statusVector = NULL);
void ERR_post_nothrow(const Firebird::IStatus* v, Jrd::FbStatusVector* statusVector = NULL);
void ERR_punt();
void ERR_warning(const Firebird::Arg::StatusVector& v);
void ERR_log(int, int, const TEXT*);