Skip to content

Commit

Permalink
LDEV-4866 fix query parsing out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
zspitzer committed Jun 6, 2024
1 parent 170f718 commit 41dce3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/lucee/runtime/db/SQLImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public String toString(boolean pattern) {
int index = 0;
for (int i = 0; i < sqlLen; i++) {
c = strSQL.charAt(i);
if (!inQuotes && sqlLen + 1 > i) {
if (!inQuotes && i < (sqlLen - 1)) {
// read multi line
if (c == '/' && strSQL.charAt(i + 1) == '*') {
int end = strSQL.indexOf("*/", i + 2);
Expand All @@ -124,7 +124,7 @@ public String toString(boolean pattern) {
}

// read single line
if (c == '-' && strSQL.charAt(i + 1) == '-') {
if (c == '-' && i < (sqlLen - 1) && strSQL.charAt(i + 1) == '-') {
int end = strSQL.indexOf('\n', i + 1);
if (end != -1) {
i = end + 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private static SQL convert(String sql, List<SQLItems<SQLItem>> items, List<SQLIt

for (int i = 0; i < sqlLen; i++) {
c = sql.charAt(i);
if (!inQuotes && sqlLen + 1 > i) {
if (!inQuotes && i < (sqlLen - 1) ) {
// read multi line
if (c == '/' && sql.charAt(i + 1) == '*') {
int end = sql.indexOf("*/", i + 2);
Expand All @@ -158,7 +158,7 @@ private static SQL convert(String sql, List<SQLItems<SQLItem>> items, List<SQLIt
}

// read single line
if (c == '-' && sql.charAt(i + 1) == '-') {
if (c == '-' && i < (sqlLen - 1) && sql.charAt(i + 1) == '-') {
int end = sql.indexOf('\n', i + 1);
if (end != -1) {
i = end + 1;
Expand Down

0 comments on commit 41dce3a

Please sign in to comment.