fix(member-files): reject membership lookup binding and finalization errors
This commit is contained in:
1 parent
6d98887716
commit
81bb22021f
1 file changed
+7
-3
@@ -116,8 +116,8 @@ int member_files_member(struct UTUN_INSTANCE* inst, uint64_t group, uint64_t nod
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "member_files: membership query failed group=%llu: %s",
|
||||
(unsigned long long)group, sqlite3_errmsg(inst->topo_sqlite_db)); return 0;
|
||||
}
|
||||
sqlite3_bind_int64(st, 1, (sqlite3_int64)node);
|
||||
int rc = sqlite3_step(st);
|
||||
int rc = sqlite3_bind_int64(st, 1, (sqlite3_int64)node);
|
||||
if (rc == SQLITE_OK) rc = sqlite3_step(st);
|
||||
char role[16]; const char* tags = (const char*)sqlite3_column_text(st, 0);
|
||||
int storage_role = tags && json_flat_get(tags, "storage", role, sizeof(role)) == 0 && !strcmp(role, "yes");
|
||||
int allowed = rc == SQLITE_ROW && !sqlite3_column_int(st, 1) && !sqlite3_column_int(st, 3) &&
|
||||
@@ -129,7 +129,11 @@ int member_files_member(struct UTUN_INSTANCE* inst, uint64_t group, uint64_t nod
|
||||
if (rc != SQLITE_ROW && rc != SQLITE_DONE) DEBUG_ERROR(DEBUG_CATEGORY_MEDIA,
|
||||
"member_files: access check failed group=%llu node=%llu require_storage=%d sqlite_rc=%d: %s",
|
||||
(unsigned long long)group, (unsigned long long)node, storage, rc, sqlite3_errmsg(inst->topo_sqlite_db));
|
||||
sqlite3_finalize(st); return allowed;
|
||||
int final = sqlite3_finalize(st);
|
||||
if (final != SQLITE_OK) DEBUG_ERROR(DEBUG_CATEGORY_MEDIA,
|
||||
"member_files: access finalize failed group=%llu node=%llu sqlite_rc=%d: %s",
|
||||
(unsigned long long)group, (unsigned long long)node, final, sqlite3_errmsg(inst->topo_sqlite_db));
|
||||
return allowed && final == SQLITE_OK;
|
||||
}
|
||||
|
||||
int mf_server_allowed(struct member_files* f, uint64_t group, uint64_t peer, const struct mf_message* q) {
|
||||
|
||||
Reference in new issue
Block a user