Reject group avatar commands outside a running chat service
This commit is contained in:
1 parent
b6a5f98d41
commit
2bcba58131
2 files changed
+8
-3
No files matched your search
@@ -113,7 +113,8 @@ static void ga_changed(struct UTUN_INSTANCE* inst, uint64_t group) {
|
||||
}
|
||||
|
||||
int group_avatar_apply(struct UTUN_INSTANCE* inst, uint64_t group, const struct group_avatar_record* r) {
|
||||
if (!r || ga_verify(inst, group, r) < 0) return -1;
|
||||
if (!r) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT, "group avatar: missing candidate record"); return -1; }
|
||||
if (ga_verify(inst, group, r) < 0) return -1;
|
||||
struct group_avatar_record current;
|
||||
if (group_avatar_get(inst, group, ¤t) < 0) return -1;
|
||||
int newer = ga_compare(r->version, r->hash, current.version, current.hash);
|
||||
@@ -140,7 +141,8 @@ int group_avatar_apply(struct UTUN_INSTANCE* inst, uint64_t group, const struct
|
||||
}
|
||||
|
||||
int group_avatar_set(struct UTUN_INSTANCE* inst, uint64_t group, const uint8_t* data, size_t size) {
|
||||
if (!inst || size > GROUP_AVATAR_MAX || (size && !data) || !member_files_member(inst, group, inst->node_id, 0)) {
|
||||
if (!inst || !CC(inst) || !CC(inst)->initialized || !CC(inst)->db || size > GROUP_AVATAR_MAX ||
|
||||
(size && !data) || !member_files_member(inst, group, inst->node_id, 0)) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_CHAT, "group avatar: publication denied group=%llu bytes=%zu", (unsigned long long)group, size); return -1;
|
||||
}
|
||||
uint8_t key[32], bytes[GROUP_AVATAR_MAX + 64]; char ch[32]; ga_channel(group, ch);
|
||||
|
||||
Reference in new issue
Block a user