Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dqlite will core dump if you put an invalid type in a column #733

Open
SimonRichardson opened this issue Jan 23, 2025 · 0 comments
Open

Comments

@SimonRichardson
Copy link
Member

SimonRichardson commented Jan 23, 2025

If for any reason you put an incorrect value in a column that isn't of the same type, dqlite will core dump.

Core dumps are currently non-recoverable, so this is extremely problematic.

The offending lines:

dqlite/src/query.c

Lines 7 to 30 in 7a37bdf

static int value_type(sqlite3_stmt *stmt, int i)
{
int type = sqlite3_column_type(stmt, i);
const char *column_type_name = sqlite3_column_decltype(stmt, i);
if (column_type_name != NULL) {
if ((strcasecmp(column_type_name, "DATETIME") == 0) ||
(strcasecmp(column_type_name, "DATE") == 0) ||
(strcasecmp(column_type_name, "TIMESTAMP") == 0)) {
if (type == SQLITE_INTEGER) {
type = DQLITE_UNIXTIME;
} else {
assert(type == SQLITE_TEXT ||
type == SQLITE_NULL);
type = DQLITE_ISO8601;
}
} else if (strcasecmp(column_type_name, "BOOLEAN") == 0) {
assert(type == SQLITE_INTEGER || type == SQLITE_NULL);
type = DQLITE_BOOLEAN;
}
}
assert(type < 16);
return type;
}

In sqlite this will return the type regardless of the value. I think dqlite should follow what sqlite does here.

Note: if we compile in release mode, it prevents us from identifying other problems/issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant