mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 06:03:02 +01:00
1) Fixed XCP_MESSAGE_LENGTH to represent the real max length. We have the column defined as VARCHAR(1023), so there's no need to subtract the overhead.
2) Slightly refactored the message buffer management. 3) Fixed the buffer overrun in the release build.
This commit is contained in:
parent
ff8d492043
commit
81466c3768
@ -4677,6 +4677,9 @@ void CreateAlterExceptionNode::execute(thread_db* tdbb, DsqlCompilerScratch* dsq
|
||||
{
|
||||
fb_assert(create || alter);
|
||||
|
||||
if (message.length() > XCP_MESSAGE_LENGTH)
|
||||
status_exception::raise(Arg::Gds(isc_dyn_name_longer));
|
||||
|
||||
// run all statements under savepoint control
|
||||
AutoSavePoint savePoint(tdbb, transaction);
|
||||
|
||||
@ -4733,7 +4736,6 @@ void CreateAlterExceptionNode::executeCreate(thread_db* tdbb, DsqlCompilerScratc
|
||||
X.RDB$OWNER_NAME.NULL = FALSE;
|
||||
strcpy(X.RDB$OWNER_NAME, userName.c_str());
|
||||
|
||||
fb_assert(message.length() < sizeof(X.RDB$MESSAGE));
|
||||
strcpy(X.RDB$MESSAGE, message.c_str());
|
||||
}
|
||||
END_STORE
|
||||
@ -4771,7 +4773,6 @@ bool CreateAlterExceptionNode::executeAlter(thread_db* tdbb, DsqlCompilerScratch
|
||||
DDL_TRIGGER_ALTER_EXCEPTION, name);
|
||||
|
||||
MODIFY X
|
||||
fb_assert(message.length() < sizeof(X.RDB$MESSAGE));
|
||||
strcpy(X.RDB$MESSAGE, message.c_str());
|
||||
|
||||
modified = true;
|
||||
|
@ -4127,38 +4127,23 @@ void ExceptionNode::setError(thread_db* tdbb) const
|
||||
|
||||
MetaName exName;
|
||||
MetaName relationName;
|
||||
TEXT message[XCP_MESSAGE_LENGTH + 1];
|
||||
MoveBuffer temp;
|
||||
USHORT length = 0;
|
||||
string message;
|
||||
|
||||
if (messageExpr)
|
||||
{
|
||||
UCHAR* string = NULL;
|
||||
|
||||
// Evaluate exception message and convert it to string.
|
||||
dsc* desc = EVL_expr(tdbb, request, messageExpr);
|
||||
const dsc* const desc = EVL_expr(tdbb, request, messageExpr);
|
||||
|
||||
if (desc && !(request->req_flags & req_null))
|
||||
{
|
||||
length = MOV_make_string2(tdbb, desc, CS_METADATA, &string, temp);
|
||||
length = MIN(length, sizeof(message) - 1);
|
||||
|
||||
/* dimitr: or should we throw an error here, i.e.
|
||||
replace the above assignment with the following lines:
|
||||
|
||||
if (length > sizeof(message) - 1)
|
||||
ERR_post(Arg::Gds(isc_imp_exc) << Arg::Gds(isc_blktoobig));
|
||||
*/
|
||||
|
||||
memcpy(message, string, length);
|
||||
MoveBuffer temp;
|
||||
UCHAR* string = NULL;
|
||||
const USHORT length = MOV_make_string2(tdbb, desc, CS_METADATA, &string, temp);
|
||||
message.assign(string, MIN(length, XCP_MESSAGE_LENGTH));
|
||||
}
|
||||
else
|
||||
length = 0;
|
||||
}
|
||||
|
||||
message[length] = 0;
|
||||
|
||||
SLONG xcpCode = exception->code;
|
||||
const SLONG xcpCode = exception->code;
|
||||
|
||||
switch (exception->type)
|
||||
{
|
||||
@ -4184,8 +4169,8 @@ void ExceptionNode::setError(thread_db* tdbb) const
|
||||
// Solves SF Bug #494981.
|
||||
MET_lookup_exception(tdbb, xcpCode, exName, &tempStr);
|
||||
|
||||
if (message[0])
|
||||
s = message;
|
||||
if (message.hasData())
|
||||
s = message.c_str();
|
||||
else if (tempStr.hasData())
|
||||
s = tempStr.c_str();
|
||||
else
|
||||
|
@ -631,10 +631,8 @@ public:
|
||||
void as_sqlstate(char*) const;
|
||||
};
|
||||
|
||||
// must correspond to the size of RDB$EXCEPTIONS.RDB$MESSAGE
|
||||
// minus size of vary::vary_length (USHORT) since RDB$MESSAGE
|
||||
// declared as varchar
|
||||
const int XCP_MESSAGE_LENGTH = 1023 - sizeof(USHORT);
|
||||
// must correspond to the declared size of RDB$EXCEPTIONS.RDB$MESSAGE
|
||||
const int XCP_MESSAGE_LENGTH = 1023;
|
||||
|
||||
} // namespace Jrd
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user