Skip to content

Commit

Permalink
[CBRD-24905] The problem is that a core dump occurs when a value of a…
Browse files Browse the repository at this point in the history
…n invalid index type (such as Collection Type) is bound to host variables (#4614) (#4630)

http://jira.cubrid.org/browse/CBRD-24905

backport #4614
  • Loading branch information
youngjinj authored Sep 1, 2023
1 parent 5584594 commit 3a55de0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 13 additions & 3 deletions src/query/scan_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,7 @@ scan_dbvals_to_midxkey (THREAD_ENTRY * thread_p, DB_VALUE * retval, bool * index
bool need_new_setdomain = false;
TP_DOMAIN *idx_setdomain = NULL, *vals_setdomain = NULL;
TP_DOMAIN *idx_dom = NULL, *val_dom = NULL, *dom = NULL, *next = NULL;
DB_TYPE idx_type_id;
TP_DOMAIN dom_buf;
DB_VALUE *coerced_values = NULL;
bool *has_coerced_values = NULL;
Expand Down Expand Up @@ -1573,7 +1574,16 @@ scan_dbvals_to_midxkey (THREAD_ENTRY * thread_p, DB_VALUE * retval, bool * index
}
}

idx_type_id = TP_DOMAIN_TYPE (idx_dom);
val_type_id = DB_VALUE_DOMAIN_TYPE (val);

if (!tp_valid_indextype (val_type_id))
{
er_set (ER_ERROR_SEVERITY, ARG_FILE_LINE, ER_TP_CANT_COERCE, 2, pr_type_name (idx_type_id),
pr_type_name (val_type_id));
goto err_exit;
}

if (TP_IS_STRING_TYPE (val_type_id))
{
/* we need to check for maxes */
Expand All @@ -1588,7 +1598,7 @@ scan_dbvals_to_midxkey (THREAD_ENTRY * thread_p, DB_VALUE * retval, bool * index
}
}

if (TP_DOMAIN_TYPE (idx_dom) != val_type_id)
if (idx_type_id != val_type_id)
{
/* allocate DB_VALUE array to store coerced values. */
if (has_coerced_values == NULL)
Expand Down Expand Up @@ -1623,8 +1633,8 @@ scan_dbvals_to_midxkey (THREAD_ENTRY * thread_p, DB_VALUE * retval, bool * index
has_coerced_values[i] = true;
}
}
else if (TP_DOMAIN_TYPE (idx_dom) == DB_TYPE_NUMERIC || TP_DOMAIN_TYPE (idx_dom) == DB_TYPE_CHAR
|| TP_DOMAIN_TYPE (idx_dom) == DB_TYPE_BIT || TP_DOMAIN_TYPE (idx_dom) == DB_TYPE_NCHAR)
else if (idx_type_id == DB_TYPE_NUMERIC || idx_type_id == DB_TYPE_CHAR || idx_type_id == DB_TYPE_BIT
|| idx_type_id == DB_TYPE_NCHAR)
{
/* skip variable string domain : DB_TYPE_VARCHAR, DB_TYPE_VARNCHAR, DB_TYPE_VARBIT */

Expand Down
6 changes: 3 additions & 3 deletions src/storage/btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -18685,9 +18685,6 @@ btree_compare_key (DB_VALUE * key1, DB_VALUE * key2, TP_DOMAIN * key_domain, int
assert (key1_type != DB_TYPE_MIDXKEY);
assert (key2_type != DB_TYPE_MIDXKEY);

assert (tp_valid_indextype (key1_type));
assert (tp_valid_indextype (key2_type));

/* safe code */
if (key1_type == DB_TYPE_MIDXKEY)
{
Expand Down Expand Up @@ -18732,6 +18729,9 @@ btree_compare_key (DB_VALUE * key1, DB_VALUE * key2, TP_DOMAIN * key_domain, int
}
}

assert (tp_valid_indextype (key1_type));
assert (tp_valid_indextype (key2_type));

assert_release (c == DB_UNK || (DB_LT <= c && c <= DB_GT));

/* for single-column desc index */
Expand Down

0 comments on commit 3a55de0

Please sign in to comment.