mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 07:23:03 +01:00
Fixed bug CORE-2908 : Engine could crash or raise not expected errors working with ODS 8.x database
This commit is contained in:
parent
4c75948482
commit
108acc7aa4
@ -375,6 +375,7 @@ public:
|
||||
USHORT dbb_dp_per_pp; // data pages per pointer page
|
||||
USHORT dbb_max_records; // max record per data page
|
||||
USHORT dbb_max_idx; // max number of indexes on a root page
|
||||
USHORT dbb_max_sys_rel; // max id of system relation
|
||||
USHORT dbb_use_count; // active count of threads
|
||||
|
||||
#ifdef SUPERSERVER_V2
|
||||
|
@ -1990,7 +1990,7 @@ IndexLock* CMP_get_index_lock(thread_db* tdbb, jrd_rel* relation, USHORT id)
|
||||
|
||||
DEV_BLKCHK(relation, type_rel);
|
||||
|
||||
if (relation->rel_id < (USHORT) rel_MAX) {
|
||||
if (relation->rel_id <= dbb->dbb_max_sys_rel) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,6 @@
|
||||
|
||||
/* Define range of user relation ids */
|
||||
|
||||
const int MIN_RELATION_ID = rel_MAX;
|
||||
const int MAX_RELATION_ID = 32767;
|
||||
|
||||
const int COMPUTED_FLAG = 128;
|
||||
@ -2485,15 +2484,8 @@ static bool create_relation(thread_db* tdbb,
|
||||
|
||||
SET_TDBB(tdbb);
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
const USHORT major_version = dbb->dbb_ods_version;
|
||||
const USHORT minor_original = dbb->dbb_minor_original;
|
||||
|
||||
USHORT local_min_relation_id;
|
||||
if (ENCODE_ODS(major_version, minor_original) < ODS_9_0)
|
||||
local_min_relation_id = MIN_RELATION_ID;
|
||||
else
|
||||
local_min_relation_id = USER_DEF_REL_INIT_ID;
|
||||
|
||||
USHORT local_min_relation_id = dbb->dbb_max_sys_rel + 1;
|
||||
switch (phase)
|
||||
{
|
||||
case 0:
|
||||
|
@ -632,6 +632,14 @@ void INI_init2(thread_db* tdbb)
|
||||
|
||||
const USHORT major_version = dbb->dbb_ods_version;
|
||||
const USHORT minor_original = dbb->dbb_minor_original;
|
||||
|
||||
if (ENCODE_ODS(major_version, minor_original) < ODS_9_0) {
|
||||
dbb->dbb_max_sys_rel = USER_REL_INIT_ID_ODS8 - 1;
|
||||
}
|
||||
else {
|
||||
dbb->dbb_max_sys_rel = USER_DEF_REL_INIT_ID - 1;
|
||||
}
|
||||
|
||||
vec<jrd_rel*>* vector = dbb->dbb_relations;
|
||||
|
||||
const int* fld;
|
||||
|
@ -2684,7 +2684,7 @@ jrd_rel* MET_lookup_relation_id(thread_db* tdbb, SLONG id, bool return_deleted)
|
||||
|
||||
/* System relations are above suspicion */
|
||||
|
||||
if (id < (int) rel_MAX)
|
||||
if (id <= (int) dbb->dbb_max_sys_rel)
|
||||
{
|
||||
fb_assert(id < MAX_USHORT);
|
||||
return MET_relation(tdbb, (USHORT) id);
|
||||
@ -3372,19 +3372,6 @@ jrd_rel* MET_relation(thread_db* tdbb, USHORT id)
|
||||
return relation;
|
||||
}
|
||||
|
||||
const USHORT major_version = dbb->dbb_ods_version;
|
||||
const USHORT minor_original = dbb->dbb_minor_original;
|
||||
|
||||
/* From ODS 9 onwards, the first 128 relation IDS have been
|
||||
reserved for system relations */
|
||||
USHORT max_sys_rel;
|
||||
if (ENCODE_ODS(major_version, minor_original) < ODS_9_0) {
|
||||
max_sys_rel = USER_REL_INIT_ID_ODS8 - 1;
|
||||
}
|
||||
else {
|
||||
max_sys_rel = USER_DEF_REL_INIT_ID - 1;
|
||||
}
|
||||
|
||||
relation = FB_NEW(*dbb->dbb_permanent) jrd_rel(*dbb->dbb_permanent);
|
||||
(*vector)[id] = relation;
|
||||
relation->rel_id = id;
|
||||
@ -3403,7 +3390,7 @@ jrd_rel* MET_relation(thread_db* tdbb, USHORT id)
|
||||
}
|
||||
|
||||
// This should check system flag instead.
|
||||
if (relation->rel_id <= max_sys_rel) {
|
||||
if (relation->rel_id <= dbb->dbb_max_sys_rel) {
|
||||
return relation;
|
||||
}
|
||||
|
||||
|
@ -734,16 +734,19 @@ void SCL_init(thread_db* tdbb, bool create, const UserId& tempId)
|
||||
END_FOR;
|
||||
CMP_release(tdbb, handle1);
|
||||
|
||||
FOR(REQUEST_HANDLE handle2) R IN RDB$ROLES
|
||||
WITH R.RDB$ROLE_NAME EQ role_name.c_str()
|
||||
if (!preODS9)
|
||||
{
|
||||
FOR(REQUEST_HANDLE handle2) R IN RDB$ROLES
|
||||
WITH R.RDB$ROLE_NAME EQ role_name.c_str()
|
||||
|
||||
if (!R.RDB$SYSTEM_FLAG.NULL)
|
||||
{
|
||||
if (R.RDB$SYSTEM_FLAG & ROLE_FLAG_DBO)
|
||||
user->usr_flags |= USR_dba;
|
||||
}
|
||||
END_FOR;
|
||||
CMP_release(tdbb, handle2);
|
||||
if (!R.RDB$SYSTEM_FLAG.NULL)
|
||||
{
|
||||
if (R.RDB$SYSTEM_FLAG & ROLE_FLAG_DBO)
|
||||
user->usr_flags |= USR_dba;
|
||||
}
|
||||
END_FOR;
|
||||
CMP_release(tdbb, handle2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
user->usr_flags |= USR_owner;
|
||||
|
@ -1165,7 +1165,7 @@ static void walk_database(thread_db* tdbb, vdr* control)
|
||||
for (USHORT i = 0; (vector = dbb->dbb_relations) && i < vector->count(); i++)
|
||||
{
|
||||
#ifdef DEBUG_VAL_VERBOSE
|
||||
if (i >= 32 /* rel_MAX */ ) // Why not system flag instead?
|
||||
if (i > dbb->dbb_max_sys_rel) // Why not system flag instead?
|
||||
VAL_debug_level = 2;
|
||||
#endif
|
||||
jrd_rel* relation = (*vector)[i];
|
||||
|
@ -1165,6 +1165,7 @@ void VIO_erase(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
|
||||
SqlIdentifier relation_name, revokee, privilege, procedure_name;
|
||||
|
||||
SET_TDBB(tdbb);
|
||||
Database* dbb = tdbb->getDatabase();
|
||||
jrd_req* request = tdbb->getRequest();
|
||||
|
||||
#ifdef VIO_DEBUG
|
||||
@ -1230,7 +1231,7 @@ void VIO_erase(thread_db* tdbb, record_param* rpb, jrd_tra* transaction)
|
||||
if (EVL_field(0, rpb->rpb_record, f_rel_id, &desc2))
|
||||
{
|
||||
id = MOV_get_long(&desc2, 0);
|
||||
if (id < (int) rel_MAX)
|
||||
if (id <= dbb->dbb_max_sys_rel)
|
||||
{
|
||||
IBERROR(187); // msg 187 cannot delete system relations
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user