Skip to content

c/driver/common/utils.c: tables are found when they should not #1100

@OleMussmann

Description

@OleMussmann

Certain string matchings fail in c/driver/common/utils.c when trying to find a table by name. A loop iterates through all tables and tries to find a match. The matching code is currently:

if (!strncmp(name.data, table_name, name.size_bytes) { return table; }

name.data is a contiguous buffer of table names, like adbc_pkey_testtest_canceladbc_fkey_test_baseadbc_fkey_testadbc_composite_pk[...]. The table_name (let's say adbc_pkey_test) is now compared to the first name.size_bytes of this buffer, which usually works out. If a non-existing table_name string is composed of an existing table name plus starting characters of another table, a match can be made where there is none. A correctly matching example is:

adbc_pkey_test
adbc_pkey_testtest_canceladbc_fkey_test_baseadbc_fkey_testadbc_composite_pk[...]
             ^
(compared until here)

An example that matches erroneously is:

adbc_pkey_testtest
adbc_pkey_testtest_canceladbc_fkey_test_baseadbc_fkey_testadbc_composite_pk[...]
                 ^
(compared until here)

N.B.: The tables are returned in nondeterministic order, so this might not fail reliably.

Software version: current main branch 8a832d6

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions