mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-13 08:13:47 +01:00
Use sqlite3_mprintf for proper escaping
Not that is really needed here since every argument is controlled by us. But rather safe than sorry. Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
12aa509fc2
commit
3e5bfe3d59
@ -265,9 +265,14 @@ prepare_statement(sqlite3* session, const char* statement)
|
|||||||
static bool
|
static bool
|
||||||
check_column(sqlite3* session, const char* table, const char* col, bool* res)
|
check_column(sqlite3* session, const char* table, const char* col, bool* res)
|
||||||
{
|
{
|
||||||
char* query = g_strdup_printf("PRAGMA table_info(%s);", table);
|
/* we can't actually bind the argument with sqlite3_bind_text because
|
||||||
sqlite3_stmt* stmt = prepare_statement(session, query);
|
* sqlite3_prepare_v2 fails with "PRAGMA table_info(?);" */
|
||||||
|
char* query = sqlite3_mprintf("PRAGMA table_info(%Q);", table);
|
||||||
|
if (query == NULL) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlite3_stmt* stmt = prepare_statement(session, query);
|
||||||
if (stmt == NULL) {
|
if (stmt == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -286,7 +291,7 @@ check_column(sqlite3* session, const char* table, const char* col, bool* res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
g_free(query);
|
sqlite3_free(query);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user