Commit 2ab999f4 authored by topjohnwu's avatar topjohnwu

Fix bug in DB query wrapper

parent c9f390d6
...@@ -195,7 +195,7 @@ static int settings_cb(void *v, int col_num, char **data, char **col_name) { ...@@ -195,7 +195,7 @@ static int settings_cb(void *v, int col_num, char **data, char **col_name) {
int get_db_settings(db_settings *dbs, int key) { int get_db_settings(db_settings *dbs, int key) {
char *err; char *err;
if (key > 0) { if (key >= 0) {
char query[128]; char query[128];
sprintf(query, "SELECT key, value FROM settings WHERE key='%s'", DB_SETTING_KEYS[key]); sprintf(query, "SELECT key, value FROM settings WHERE key='%s'", DB_SETTING_KEYS[key]);
err = db_exec(query, settings_cb, dbs); err = db_exec(query, settings_cb, dbs);
...@@ -225,7 +225,7 @@ static int strings_cb(void *v, int col_num, char **data, char **col_name) { ...@@ -225,7 +225,7 @@ static int strings_cb(void *v, int col_num, char **data, char **col_name) {
int get_db_strings(db_strings *str, int key) { int get_db_strings(db_strings *str, int key) {
char *err; char *err;
if (key > 0) { if (key >= 0) {
char query[128]; char query[128];
sprintf(query, "SELECT key, value FROM strings WHERE key='%s'", DB_STRING_KEYS[key]); sprintf(query, "SELECT key, value FROM strings WHERE key='%s'", DB_STRING_KEYS[key]);
err = db_exec(query, strings_cb, str); err = db_exec(query, strings_cb, str);
......
...@@ -136,8 +136,8 @@ struct su_access { ...@@ -136,8 +136,8 @@ struct su_access {
********************/ ********************/
sqlite3 *get_magiskdb(sqlite3 *&db); sqlite3 *get_magiskdb(sqlite3 *&db);
int get_db_settings(db_settings *dbs, int key); int get_db_settings(db_settings *dbs, int key = -1);
int get_db_strings(db_strings *str, int key); int get_db_strings(db_strings *str, int key = -1);
int get_uid_policy(int uid, struct su_access *su); int get_uid_policy(int uid, struct su_access *su);
int validate_manager(char *alt_pkg, int userid, struct stat *st); int validate_manager(char *alt_pkg, int userid, struct stat *st);
void exec_sql(int client); void exec_sql(int client);
......
...@@ -60,8 +60,8 @@ static void *info_collector(void *node) { ...@@ -60,8 +60,8 @@ static void *info_collector(void *node) {
static void database_check(su_info *info) { static void database_check(su_info *info) {
int uid = info->uid; int uid = info->uid;
get_db_settings(&info->cfg, 0); get_db_settings(&info->cfg);
get_db_strings(&info->str, 0); get_db_strings(&info->str);
// Check multiuser settings // Check multiuser settings
switch (info->cfg[SU_MULTIUSER_MODE]) { switch (info->cfg[SU_MULTIUSER_MODE]) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment