|
From: <asf...@us...> - 2015-08-05 16:44:50
|
Revision: 62076
http://sourceforge.net/p/firebird/code/62076
Author: asfernandes
Date: 2015-08-05 16:44:48 +0000 (Wed, 05 Aug 2015)
Log Message:
-----------
Fixed CORE-4884 - Crash on pasring of script containing `execute block` with lot of nested begin..end statements.
Modified Paths:
--------------
firebird/trunk/lang_helpers/gds_codes.ftn
firebird/trunk/lang_helpers/gds_codes.pas
firebird/trunk/src/dsql/DsqlCompilerScratch.h
firebird/trunk/src/dsql/StmtNodes.cpp
firebird/trunk/src/include/gen/codetext.h
firebird/trunk/src/include/gen/iberror.h
firebird/trunk/src/include/gen/msgs.h
firebird/trunk/src/include/gen/sql_code.h
firebird/trunk/src/include/gen/sql_state.h
firebird/trunk/src/msgs/facilities2.sql
firebird/trunk/src/msgs/messages2.sql
firebird/trunk/src/msgs/system_errors2.sql
Modified: firebird/trunk/lang_helpers/gds_codes.ftn
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.ftn 2015-08-03 01:41:34 UTC (rev 62075)
+++ firebird/trunk/lang_helpers/gds_codes.ftn 2015-08-05 16:44:48 UTC (rev 62076)
@@ -2338,6 +2338,8 @@
PARAMETER (GDS__dsql_string_byte_length = 336397331)
INTEGER*4 GDS__dsql_string_char_length
PARAMETER (GDS__dsql_string_char_length = 336397332)
+ INTEGER*4 GDS__dsql_max_nesting
+ PARAMETER (GDS__dsql_max_nesting = 336397333)
INTEGER*4 GDS__gsec_cant_open_db
PARAMETER (GDS__gsec_cant_open_db = 336723983)
INTEGER*4 GDS__gsec_switches_error
Modified: firebird/trunk/lang_helpers/gds_codes.pas
===================================================================
--- firebird/trunk/lang_helpers/gds_codes.pas 2015-08-03 01:41:34 UTC (rev 62075)
+++ firebird/trunk/lang_helpers/gds_codes.pas 2015-08-05 16:44:48 UTC (rev 62076)
@@ -1176,6 +1176,7 @@
gds_dsql_max_exception_arguments = 336397330;
gds_dsql_string_byte_length = 336397331;
gds_dsql_string_char_length = 336397332;
+ gds_dsql_max_nesting = 336397333;
gds_gsec_cant_open_db = 336723983;
gds_gsec_switches_error = 336723984;
gds_gsec_no_op_spec = 336723985;
Modified: firebird/trunk/src/dsql/DsqlCompilerScratch.h
===================================================================
--- firebird/trunk/src/dsql/DsqlCompilerScratch.h 2015-08-03 01:41:34 UTC (rev 62075)
+++ firebird/trunk/src/dsql/DsqlCompilerScratch.h 2015-08-05 16:44:48 UTC (rev 62076)
@@ -65,6 +65,8 @@
static const unsigned FLAG_DDL = 0x2000;
static const unsigned FLAG_FETCH = 0x4000;
+ static const unsigned MAX_NESTING = 512;
+
public:
DsqlCompilerScratch(MemoryPool& p, dsql_dbb* aDbb, jrd_tra* aTransaction,
DsqlCompiledStatement* aStatement)
@@ -73,6 +75,7 @@
transaction(aTransaction),
statement(aStatement),
flags(0),
+ nestingLevel(0),
ports(p),
relation(NULL),
procedure(NULL),
@@ -288,6 +291,7 @@
public:
unsigned flags; // flags
+ unsigned nestingLevel; // begin...end nesting level
Firebird::Array<dsql_msg*> ports; // Port messages
dsql_rel* relation; // relation created by this request (for DDL)
dsql_prc* procedure; // procedure created by this request (for DDL)
Modified: firebird/trunk/src/dsql/StmtNodes.cpp
===================================================================
--- firebird/trunk/src/dsql/StmtNodes.cpp 2015-08-03 01:41:34 UTC (rev 62075)
+++ firebird/trunk/src/dsql/StmtNodes.cpp 2015-08-05 16:44:48 UTC (rev 62076)
@@ -769,6 +769,13 @@
CompoundStmtNode* CompoundStmtNode::dsqlPass(DsqlCompilerScratch* dsqlScratch)
{
+ if (++dsqlScratch->nestingLevel > DsqlCompilerScratch::MAX_NESTING)
+ {
+ ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) <<
+ Arg::Gds(isc_imp_exc) <<
+ Arg::Gds(isc_dsql_max_nesting) << Arg::Num(DsqlCompilerScratch::MAX_NESTING));
+ }
+
CompoundStmtNode* node = FB_NEW(getPool()) CompoundStmtNode(getPool());
for (NestConst<StmtNode>* i = statements.begin(); i != statements.end(); ++i)
@@ -778,6 +785,8 @@
node->statements.add(ptr);
}
+ --dsqlScratch->nestingLevel;
+
return node;
}
Modified: firebird/trunk/src/include/gen/codetext.h
===================================================================
--- firebird/trunk/src/include/gen/codetext.h 2015-08-03 01:41:34 UTC (rev 62075)
+++ firebird/trunk/src/include/gen/codetext.h 2015-08-05 16:44:48 UTC (rev 62076)
@@ -1165,6 +1165,7 @@
{"dsql_max_exception_arguments", 336397330},
{"dsql_string_byte_length", 336397331},
{"dsql_string_char_length", 336397332},
+ {"dsql_max_nesting", 336397333},
{"gsec_cant_open_db", 336723983},
{"gsec_switches_error", 336723984},
{"gsec_no_op_spec", 336723985},
Modified: firebird/trunk/src/include/gen/iberror.h
===================================================================
--- firebird/trunk/src/include/gen/iberror.h 2015-08-03 01:41:34 UTC (rev 62075)
+++ firebird/trunk/src/include/gen/iberror.h 2015-08-05 16:44:48 UTC (rev 62076)
@@ -1199,6 +1199,7 @@
const ISC_STATUS isc_dsql_max_exception_arguments = 336397330L;
const ISC_STATUS isc_dsql_string_byte_length = 336397331L;
const ISC_STATUS isc_dsql_string_char_length = 336397332L;
+const ISC_STATUS isc_dsql_max_nesting = 336397333L;
const ISC_STATUS isc_gsec_cant_open_db = 336723983L;
const ISC_STATUS isc_gsec_switches_error = 336723984L;
const ISC_STATUS isc_gsec_no_op_spec = 336723985L;
@@ -1301,7 +1302,7 @@
const ISC_STATUS isc_trace_switch_param_miss = 337182758L;
const ISC_STATUS isc_trace_param_act_notcompat = 337182759L;
const ISC_STATUS isc_trace_mandatory_switch_miss = 337182760L;
-const ISC_STATUS isc_err_max = 1245;
+const ISC_STATUS isc_err_max = 1246;
#else /* c definitions */
@@ -2470,6 +2471,7 @@
#define isc_dsql_max_exception_arguments 336397330L
#define isc_dsql_string_byte_length 336397331L
#define isc_dsql_string_char_length 336397332L
+#define isc_dsql_max_nesting 336397333L
#define isc_gsec_cant_open_db 336723983L
#define isc_gsec_switches_error 336723984L
#define isc_gsec_no_op_spec 336723985L
@@ -2572,7 +2574,7 @@
#define isc_trace_switch_param_miss 337182758L
#define isc_trace_param_act_notcompat 337182759L
#define isc_trace_mandatory_switch_miss 337182760L
-#define isc_err_max 1245
+#define isc_err_max 1246
#endif
Modified: firebird/trunk/src/include/gen/msgs.h
===================================================================
--- firebird/trunk/src/include/gen/msgs.h 2015-08-03 01:41:34 UTC (rev 62075)
+++ firebird/trunk/src/include/gen/msgs.h 2015-08-05 16:44:48 UTC (rev 62076)
@@ -1168,6 +1168,7 @@
{336397330, "Number of arguments (@1) exceeds the maximum (@2) number of EXCEPTION USING arguments"}, /* dsql_max_exception_arguments */
{336397331, "String literal with @1 bytes exceeds the maximum length of @2 bytes"}, /* dsql_string_byte_length */
{336397332, "String literal with @1 characters exceeds the maximum length of @2 characters for the @3 character set"}, /* dsql_string_char_length */
+ {336397333, "Too many BEGIN...END nesting. Max level is @1"}, /* dsql_max_nesting */
{336723983, "unable to open database"}, /* gsec_cant_open_db */
{336723984, "error in switch specifications"}, /* gsec_switches_error */
{336723985, "no operation specified"}, /* gsec_no_op_spec */
Modified: firebird/trunk/src/include/gen/sql_code.h
===================================================================
--- firebird/trunk/src/include/gen/sql_code.h 2015-08-03 01:41:34 UTC (rev 62075)
+++ firebird/trunk/src/include/gen/sql_code.h 2015-08-05 16:44:48 UTC (rev 62076)
@@ -1164,6 +1164,7 @@
{336397330, -901}, /* 1042 dsql_max_exception_arguments */
{336397331, -901}, /* 1043 dsql_string_byte_length */
{336397332, -901}, /* 1044 dsql_string_char_length */
+ {336397333, -901}, /* 1045 dsql_max_nesting */
{336723983, -901}, /* 15 gsec_cant_open_db */
{336723984, -901}, /* 16 gsec_switches_error */
{336723985, -901}, /* 17 gsec_no_op_spec */
Modified: firebird/trunk/src/include/gen/sql_state.h
===================================================================
--- firebird/trunk/src/include/gen/sql_state.h 2015-08-03 01:41:34 UTC (rev 62075)
+++ firebird/trunk/src/include/gen/sql_state.h 2015-08-05 16:44:48 UTC (rev 62076)
@@ -1164,6 +1164,7 @@
{336397330, "07002"}, // 1042 dsql_max_exception_arguments
{336397331, "42000"}, // 1043 dsql_string_byte_length
{336397332, "42000"}, // 1044 dsql_string_char_length
+ {336397333, "07002"}, // 1045 dsql_max_nesting
{336723983, "00000"}, // 15 gsec_cant_open_db
{336723984, "00000"}, // 16 gsec_switches_error
{336723985, "00000"}, // 17 gsec_no_op_spec
Modified: firebird/trunk/src/msgs/facilities2.sql
===================================================================
--- firebird/trunk/src/msgs/facilities2.sql 2015-08-03 01:41:34 UTC (rev 62075)
+++ firebird/trunk/src/msgs/facilities2.sql 2015-08-05 16:44:48 UTC (rev 62076)
@@ -10,7 +10,7 @@
('1996-11-07 13:39:40', 'INSTALL', 10, 1)
('1996-11-07 13:38:41', 'TEST', 11, 4)
('2015-07-23 14:20:00', 'GBAK', 12, 370)
-('2015-05-04 13:00:00', 'SQLERR', 13, 1044)
+('2015-08-05 12:40:00', 'SQLERR', 13, 1045)
('1996-11-07 13:38:42', 'SQLWARN', 14, 613)
('2006-09-10 03:04:31', 'JRD_BUGCHK', 15, 307)
('2014-05-07 03:04:46', 'ISQL', 17, 190)
Modified: firebird/trunk/src/msgs/messages2.sql
===================================================================
--- firebird/trunk/src/msgs/messages2.sql 2015-08-03 01:41:34 UTC (rev 62075)
+++ firebird/trunk/src/msgs/messages2.sql 2015-08-05 16:44:48 UTC (rev 62076)
@@ -2630,6 +2630,7 @@
('dsql_max_exception_arguments', NULL, 'StmtNodes.cpp', NULL, 13, 1042, NULL, 'Number of arguments (@1) exceeds the maximum (@2) number of EXCEPTION USING arguments', NULL, NULL);
('dsql_string_byte_length', NULL, 'Parser.cpp', NULL, 13, 1043, NULL, 'String literal with @1 bytes exceeds the maximum length of @2 bytes', NULL, NULL);
('dsql_string_char_length', NULL, 'Parser.cpp', NULL, 13, 1044, NULL, 'String literal with @1 characters exceeds the maximum length of @2 characters for the @3 character set', NULL, NULL);
+('dsql_max_nesting', NULL, 'StmtNodes.cpp', NULL, 13, 1045, NULL, 'Too many BEGIN...END nesting. Maximum level is @1', NULL, NULL);
-- SQLWARN
(NULL, NULL, NULL, NULL, 14, 100, NULL, 'Row not found for fetch, update or delete, or the result of a query is an empty table.', NULL, NULL);
(NULL, NULL, NULL, NULL, 14, 101, NULL, 'segment buffer length shorter than expected', NULL, NULL);
Modified: firebird/trunk/src/msgs/system_errors2.sql
===================================================================
--- firebird/trunk/src/msgs/system_errors2.sql 2015-08-03 01:41:34 UTC (rev 62075)
+++ firebird/trunk/src/msgs/system_errors2.sql 2015-08-05 16:44:48 UTC (rev 62076)
@@ -1158,6 +1158,7 @@
(-901, '07', '002', 13, 1042, 'dsql_max_exception_arguments', NULL, NULL)
(-901, '42', '000', 13, 1043, 'dsql_string_byte_length', NULL, NULL)
(-901, '42', '000', 13, 1044, 'dsql_string_char_length', NULL, NULL)
+(-901, '07', '002', 13, 1045, 'dsql_max_nesting', NULL, NULL)
-- GSEC
(-901, '00', '000', 18, 15, 'gsec_cant_open_db', NULL, NULL)
(-901, '00', '000', 18, 16, 'gsec_switches_error', NULL, NULL)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|