Skip to content

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

Description

@SimonRichardson

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions