mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 17:23:04 +01:00
Fixed CORE-3554: Server crashes during prepare or throws incorrect parsing error if the remotely passed SQL query is empty. The origin of the zero-length SQL string passed is still unknown though, so the ticket remains open for a while.
This commit is contained in:
parent
116130a22a
commit
acb020fc35
@ -657,17 +657,6 @@ static ISC_STATUS dsql8_execute_immediate_common(ISC_STATUS* user_status,
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!string) {
|
|
||||||
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104,
|
|
||||||
isc_arg_gds, isc_command_end_err2,
|
|
||||||
// CVC: Nothing will be line 1, column 1 for the user.
|
|
||||||
isc_arg_number, (SLONG) 1, isc_arg_number, (SLONG) 1,
|
|
||||||
isc_arg_end); // Unexpected end of command
|
|
||||||
}
|
|
||||||
if (!length) {
|
|
||||||
length = strlen(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Figure out which parser version to use
|
// Figure out which parser version to use
|
||||||
/* Since the API to dsql8_execute_immediate is public and can not be changed, there needs to
|
/* Since the API to dsql8_execute_immediate is public and can not be changed, there needs to
|
||||||
* be a way to send the parser version to DSQL so that the parser can compare the keyword
|
* be a way to send the parser version to DSQL so that the parser can compare the keyword
|
||||||
@ -1361,18 +1350,6 @@ ISC_STATUS GDS_DSQL_PREPARE_CPP(ISC_STATUS* user_status,
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (!string) {
|
|
||||||
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104,
|
|
||||||
isc_arg_gds, isc_command_end_err2,
|
|
||||||
// CVC: Nothing will be line 1, column 1 for the user.
|
|
||||||
isc_arg_number, (SLONG) 1, isc_arg_number, (SLONG) 1,
|
|
||||||
isc_arg_end); // Unexpected end of command
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!length) {
|
|
||||||
length = strlen(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Figure out which parser version to use
|
// Figure out which parser version to use
|
||||||
/* Since the API to dsql8_prepare is public and can not be changed, there needs to
|
/* Since the API to dsql8_prepare is public and can not be changed, there needs to
|
||||||
* be a way to send the parser version to DSQL so that the parser can compare the keyword
|
* be a way to send the parser version to DSQL so that the parser can compare the keyword
|
||||||
@ -4697,7 +4674,14 @@ static dsql_req* prepare(
|
|||||||
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901,
|
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 901,
|
||||||
isc_arg_gds, isc_wish_list, isc_arg_end);
|
isc_arg_gds, isc_wish_list, isc_arg_end);
|
||||||
|
|
||||||
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(isc_sqlerr, isc_arg_number, (SLONG) - 104,
|
ERRD_post(isc_sqlerr, isc_arg_number, (SLONG) - 104,
|
||||||
isc_arg_gds, isc_command_end_err2,
|
isc_arg_gds, isc_command_end_err2,
|
||||||
// CVC: Nothing will be line 1, column 1 for the user.
|
// CVC: Nothing will be line 1, column 1 for the user.
|
||||||
@ -4705,9 +4689,6 @@ static dsql_req* prepare(
|
|||||||
isc_arg_end); // Unexpected end of command
|
isc_arg_end); // Unexpected end of command
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string_length)
|
|
||||||
string_length = strlen(string);
|
|
||||||
|
|
||||||
/* Get rid of the trailing ";" if there is one. */
|
/* Get rid of the trailing ";" if there is one. */
|
||||||
|
|
||||||
for (const TEXT* p = string + string_length; p-- > string;)
|
for (const TEXT* p = string + string_length; p-- > string;)
|
||||||
|
@ -1594,6 +1594,14 @@ ISC_STATUS GDS_DSQL_EXECUTE_IMMED2(ISC_STATUS* user_status,
|
|||||||
rdb->rdb_status_vector = user_status;
|
rdb->rdb_status_vector = user_status;
|
||||||
tdrdb->trdb_database = rdb;
|
tdrdb->trdb_database = rdb;
|
||||||
|
|
||||||
|
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)
|
if (dialect > 10)
|
||||||
{
|
{
|
||||||
// dimitr: adjust dialect received after
|
// dimitr: adjust dialect received after
|
||||||
@ -1690,8 +1698,7 @@ ISC_STATUS GDS_DSQL_EXECUTE_IMMED2(ISC_STATUS* user_status,
|
|||||||
P_SQLST* ex_now = &packet->p_sqlst;
|
P_SQLST* ex_now = &packet->p_sqlst;
|
||||||
ex_now->p_sqlst_transaction = (transaction) ? transaction->rtr_id : 0;
|
ex_now->p_sqlst_transaction = (transaction) ? transaction->rtr_id : 0;
|
||||||
ex_now->p_sqlst_SQL_dialect = dialect;
|
ex_now->p_sqlst_SQL_dialect = dialect;
|
||||||
ex_now->p_sqlst_SQL_str.cstr_length =
|
ex_now->p_sqlst_SQL_str.cstr_length = length;
|
||||||
length ? length : strlen(string);
|
|
||||||
ex_now->p_sqlst_SQL_str.cstr_address = (UCHAR*) string;
|
ex_now->p_sqlst_SQL_str.cstr_address = (UCHAR*) string;
|
||||||
ex_now->p_sqlst_items.cstr_length = 0;
|
ex_now->p_sqlst_items.cstr_length = 0;
|
||||||
ex_now->p_sqlst_buffer_length = 0;
|
ex_now->p_sqlst_buffer_length = 0;
|
||||||
@ -2293,6 +2300,14 @@ ISC_STATUS GDS_DSQL_PREPARE(ISC_STATUS * user_status, RTR * rtr_handle, RSR * st
|
|||||||
rdb->rdb_status_vector = user_status;
|
rdb->rdb_status_vector = user_status;
|
||||||
tdrdb->trdb_database = rdb;
|
tdrdb->trdb_database = rdb;
|
||||||
|
|
||||||
|
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)
|
if (dialect > 10)
|
||||||
{
|
{
|
||||||
// dimitr: adjust dialect received after
|
// dimitr: adjust dialect received after
|
||||||
@ -2334,8 +2349,7 @@ ISC_STATUS GDS_DSQL_PREPARE(ISC_STATUS * user_status, RTR * rtr_handle, RSR * st
|
|||||||
prepare->p_sqlst_transaction = (transaction) ? transaction->rtr_id : 0;
|
prepare->p_sqlst_transaction = (transaction) ? transaction->rtr_id : 0;
|
||||||
prepare->p_sqlst_statement = statement->rsr_id;
|
prepare->p_sqlst_statement = statement->rsr_id;
|
||||||
prepare->p_sqlst_SQL_dialect = dialect;
|
prepare->p_sqlst_SQL_dialect = dialect;
|
||||||
prepare->p_sqlst_SQL_str.cstr_length =
|
prepare->p_sqlst_SQL_str.cstr_length = length;
|
||||||
length ? length : strlen(string);
|
|
||||||
prepare->p_sqlst_SQL_str.cstr_address = (UCHAR*) string;
|
prepare->p_sqlst_SQL_str.cstr_address = (UCHAR*) string;
|
||||||
prepare->p_sqlst_items.cstr_length = item_length;
|
prepare->p_sqlst_items.cstr_length = item_length;
|
||||||
prepare->p_sqlst_items.cstr_address = (UCHAR*) items;
|
prepare->p_sqlst_items.cstr_address = (UCHAR*) items;
|
||||||
|
@ -903,7 +903,14 @@ static bool alloc_cstring(XDR* xdrs,
|
|||||||
**************************************/
|
**************************************/
|
||||||
|
|
||||||
if (!cstring->cstr_length)
|
if (!cstring->cstr_length)
|
||||||
|
{
|
||||||
|
if (cstring->cstr_allocated)
|
||||||
|
*cstring->cstr_address = '\0';
|
||||||
|
else
|
||||||
|
cstring->cstr_address = NULL;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (cstring->cstr_length > cstring->cstr_allocated &&
|
if (cstring->cstr_length > cstring->cstr_allocated &&
|
||||||
cstring->cstr_allocated)
|
cstring->cstr_allocated)
|
||||||
|
Loading…
Reference in New Issue
Block a user