chat: reject unsupported encrypted attachment types before side effects

This commit is contained in:
evgeny committed 2026-10-24 17:26:11 +02:00
1 parent f63d640c95
commit d88e39fb4e
2 files changed
+2 -1

No files matched your search

+1 -1
View File
@@ -198,7 +198,7 @@ static void ak_file_done(void* arg, int error) {
int chat_attachment_send(struct UTUN_INSTANCE* inst, const char* channel, const char* source,
const struct attachment_info* info, const char* type, const uint8_t reply[32], uint64_t request) {
if (!inst || !CC(inst) || CC(inst)->attachment_closing || !inst->media_async || !ak_channel(channel) ||
!source || strlen(source) >= 1024 || !type || strlen(type) >= 32 || attachment_validate(info)) {
!source || strlen(source) >= 1024 || encrypted_file_validate_type(type) || attachment_validate(info)) {
DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "attachment keys: invalid send arguments/state"); return -1;
}
struct ak_file* job = u_calloc(1, sizeof(*job));
+1
View File
@@ -28,6 +28,7 @@ void chat_attachment_destroy(struct UTUN_INSTANCE* inst);
/* Асинхронно отправить подготовленный файл; channel — десятичный ID, reply — 32 байта ID ответа либо нули.
* Аргументы копируются. 0 — задача принята, source передан задаче и будет удалён даже при ошибке подготовки.
* -1 — отказ запуска, source остаётся у вызывающего. Ненулевой request возвращается в CHAT_EVT_MSG_SUBMITTED. */
/* type проверяется encrypted_file_validate_type до выделения задачи, генерации UUID/ключа и записи в БД. */
int chat_attachment_send(struct UTUN_INSTANCE* inst, const char* channel, const char* source,
const struct attachment_info* info, const char* type, const uint8_t reply[32], uint64_t request);