mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 01:23:03 +01:00
Front ported CORE-3554: Server crashes during prepare or throws incorrect parsing error if the remotely passed SQL query is empty.
This commit is contained in:
parent
fbcec2ce10
commit
23241eb2d3
@ -682,17 +682,6 @@ void DSQL_prepare(thread_db* tdbb,
|
||||
|
||||
dsql_req* request = NULL;
|
||||
|
||||
if (!string) {
|
||||
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
|
||||
// Unexpected end of command
|
||||
// CVC: Nothing will be line 1, column 1 for the user.
|
||||
Arg::Gds(isc_command_end_err2) << Arg::Num(1) << Arg::Num(1));
|
||||
}
|
||||
|
||||
if (!length) {
|
||||
length = strlen(string);
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// Figure out which parser version to use
|
||||
@ -1098,17 +1087,6 @@ static void execute_immediate(thread_db* tdbb,
|
||||
{
|
||||
SET_TDBB(tdbb);
|
||||
|
||||
if (!string) {
|
||||
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
|
||||
// Unexpected end of command
|
||||
// CVC: Nothing will be line 1, column 1 for the user.
|
||||
Arg::Gds(isc_command_end_err2) << Arg::Num(1) << Arg::Num(1));
|
||||
}
|
||||
|
||||
if (!length) {
|
||||
length = strlen(string);
|
||||
}
|
||||
|
||||
dsql_dbb* const database = init(attachment);
|
||||
dsql_req* request = NULL;
|
||||
|
||||
@ -2558,17 +2536,21 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
|
||||
Arg::Gds(isc_wish_list));
|
||||
}
|
||||
|
||||
if (!string) {
|
||||
if (string && !string_length)
|
||||
{
|
||||
size_t sql_length = strlen(string);
|
||||
if (sql_length > MAX_USHORT)
|
||||
sql_length = MAX_USHORT;
|
||||
string_length = static_cast<USHORT>(sql_length);
|
||||
}
|
||||
|
||||
if (!string || !string_length) {
|
||||
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
|
||||
// Unexpected end of command
|
||||
// CVC: Nothing will be line 1, column 1 for the user.
|
||||
Arg::Gds(isc_command_end_err2) << Arg::Num(1) << Arg::Num(1));
|
||||
}
|
||||
|
||||
if (!string_length) {
|
||||
string_length = strlen(string);
|
||||
}
|
||||
|
||||
// Get rid of the trailing ";" if there is one.
|
||||
|
||||
for (const TEXT* p = string + string_length; p-- > string;)
|
||||
|
@ -1496,6 +1496,14 @@ ISC_STATUS GDS_DSQL_EXECUTE_IMMED2(ISC_STATUS* user_status,
|
||||
|
||||
rdb->set_status_vector(user_status);
|
||||
|
||||
if (!length)
|
||||
{
|
||||
size_t sql_length = strlen(string);
|
||||
if (sql_length > MAX_USHORT)
|
||||
sql_length = MAX_USHORT;
|
||||
length = static_cast<USHORT>(sql_length);
|
||||
}
|
||||
|
||||
if (dialect > 10)
|
||||
{
|
||||
// dimitr: adjust dialect received after
|
||||
@ -1588,7 +1596,7 @@ ISC_STATUS GDS_DSQL_EXECUTE_IMMED2(ISC_STATUS* user_status,
|
||||
P_SQLST* ex_now = &packet->p_sqlst;
|
||||
ex_now->p_sqlst_transaction = transaction ? transaction->rtr_id : 0;
|
||||
ex_now->p_sqlst_SQL_dialect = dialect;
|
||||
ex_now->p_sqlst_SQL_str.cstr_length = length ? length : strlen(string);
|
||||
ex_now->p_sqlst_SQL_str.cstr_length = length;
|
||||
ex_now->p_sqlst_SQL_str.cstr_address = reinterpret_cast<const UCHAR*>(string);
|
||||
ex_now->p_sqlst_items.cstr_length = 0;
|
||||
ex_now->p_sqlst_buffer_length = 0;
|
||||
@ -2181,6 +2189,14 @@ ISC_STATUS GDS_DSQL_PREPARE(ISC_STATUS* user_status, Rtr** rtr_handle,
|
||||
}
|
||||
rdb->set_status_vector(user_status);
|
||||
|
||||
if (!length)
|
||||
{
|
||||
size_t sql_length = strlen(string);
|
||||
if (sql_length > MAX_USHORT)
|
||||
sql_length = MAX_USHORT;
|
||||
length = static_cast<USHORT>(sql_length);
|
||||
}
|
||||
|
||||
if (dialect > 10)
|
||||
{
|
||||
// dimitr: adjust dialect received after
|
||||
@ -2223,7 +2239,7 @@ ISC_STATUS GDS_DSQL_PREPARE(ISC_STATUS* user_status, Rtr** rtr_handle,
|
||||
prepare->p_sqlst_transaction = transaction ? transaction->rtr_id : 0;
|
||||
prepare->p_sqlst_statement = statement->rsr_id;
|
||||
prepare->p_sqlst_SQL_dialect = dialect;
|
||||
prepare->p_sqlst_SQL_str.cstr_length = length ? length : strlen(string);
|
||||
prepare->p_sqlst_SQL_str.cstr_length = length;
|
||||
prepare->p_sqlst_SQL_str.cstr_address = reinterpret_cast<const UCHAR*>(string);
|
||||
prepare->p_sqlst_items.cstr_length = item_length;
|
||||
prepare->p_sqlst_items.cstr_address = items;
|
||||
|
@ -848,7 +848,14 @@ static bool alloc_cstring(XDR* xdrs, CSTRING* cstring)
|
||||
**************************************/
|
||||
|
||||
if (!cstring->cstr_length)
|
||||
{
|
||||
if (cstring->cstr_allocated)
|
||||
*cstring->cstr_address = '\0';
|
||||
else
|
||||
cstring->cstr_address = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (cstring->cstr_length > cstring->cstr_allocated && cstring->cstr_allocated)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user