Changeset: 9ed7cf841ff0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/9ed7cf841ff0
Added Files:
        sql/test/BugTracker-2024/Tests/alloc-overflow-7432.test
Modified Files:
        monetdb5/modules/mal/txtsim.c
        sql/test/BugTracker-2024/Tests/All
Branch: Dec2023
Log Message:

Fix alloc overflow in dameraulevenshtein GH#7432.


diffs (45 lines):

diff --git a/monetdb5/modules/mal/txtsim.c b/monetdb5/modules/mal/txtsim.c
--- a/monetdb5/modules/mal/txtsim.c
+++ b/monetdb5/modules/mal/txtsim.c
@@ -76,7 +76,7 @@ dameraulevenshtein(int *res, str *S, str
        int above;                                      /* contents of cell 
immediately above */
        int left;                                       /* contents of cell 
immediately to left */
        int diag;                                       /* contents of cell 
immediately above and to left */
-       int sz;                                         /* number of cells in 
matrix */
+       lng sz;                                 /* number of cells in matrix */
        int diag2 = 0, cost2 = 0;
 
        if (strNil(*S) || strNil(*T)) {
@@ -98,7 +98,7 @@ dameraulevenshtein(int *res, str *S, str
        sz = (n + 1) * (m + 1) * sizeof(int);
        d = (int *) GDKmalloc(sz);
        if (d == NULL)
-               throw(MAL, "levenshtein", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+               throw(MAL, "dameraulevenshtein", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
 
        /* Step 2 */
        for (i = 0; i <= n; i++) {
diff --git a/sql/test/BugTracker-2024/Tests/All 
b/sql/test/BugTracker-2024/Tests/All
--- a/sql/test/BugTracker-2024/Tests/All
+++ b/sql/test/BugTracker-2024/Tests/All
@@ -3,3 +3,4 @@ pkey-check-failed-7425
 where-between-issue-7428
 where-case-null-issue-7429
 create-index-query-issue-7430
+alloc-overflow-7432
diff --git a/sql/test/BugTracker-2024/Tests/alloc-overflow-7432.test 
b/sql/test/BugTracker-2024/Tests/alloc-overflow-7432.test
new file mode 100644
--- /dev/null
+++ b/sql/test/BugTracker-2024/Tests/alloc-overflow-7432.test
@@ -0,0 +1,11 @@
+statement ok
+CREATE TABLE v0(v1 char(100))
+
+statement ok
+INSERT INTO v0 VALUES 
(222),(10),(3),(947),(742),(1),(306),(10),(510),(1.100000),(9223372036854775807),(333),(106),(10),(10),(10),(10),(10),(NULL),(222),(10.100000),(5),(2),(1),(2),(34)
+
+statement ok
+INSERT INTO v0 (v1) SELECT group_concat ('table tn3 row 99') FROM v0, v0 AS 
tri, v0 AS OMW WHERE 10 LIMIT 4
+
+statement error HY013!Could not allocate space
+SELECT levenshtein (v1, v1, 16, 10, 561), v1, v1 FROM v0
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to