Fix bug in DB query wrapper

This commit is contained in:
topjohnwu 2018-11-20 01:50:31 -05:00
parent c9f390d6e0
commit 2ab999f4ca
3 changed files with 6 additions and 6 deletions

View File

@ -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) {
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);

View File

@ -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);

View File

@ -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]) {