summaryrefslogtreecommitdiff
path: root/protocols/Tox/libtox/src/toxcore/announce.c
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Tox/libtox/src/toxcore/announce.c')
-rw-r--r--protocols/Tox/libtox/src/toxcore/announce.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/protocols/Tox/libtox/src/toxcore/announce.c b/protocols/Tox/libtox/src/toxcore/announce.c
index b983cb0574..dc34ca05e3 100644
--- a/protocols/Tox/libtox/src/toxcore/announce.c
+++ b/protocols/Tox/libtox/src/toxcore/announce.c
@@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-3.0-or-later
- * Copyright © 2020-2021 The TokTok team.
+ * Copyright © 2020-2025 The TokTok team.
*/
/**
@@ -9,7 +9,6 @@
#include "announce.h"
#include <assert.h>
-#include <stdlib.h>
#include <string.h>
#include "DHT.h"
@@ -239,9 +238,9 @@ bool announce_store_data(Announcements *announce, const uint8_t *data_public_key
if (length > 0) {
assert(data != nullptr);
- free(entry->data);
+ mem_delete(announce->mem, entry->data);
- uint8_t *entry_data = (uint8_t *)malloc(length);
+ uint8_t *entry_data = (uint8_t *)mem_balloc(announce->mem, length);
if (entry_data == nullptr) {
entry->data = nullptr; // TODO(iphydf): Is this necessary?
@@ -451,7 +450,7 @@ static int create_reply_plain_store_announce_request(Announcements *announce,
return -1;
}
- if (decrypt_data_symmetric(shared_key,
+ if (decrypt_data_symmetric(announce->mem, shared_key,
data + CRYPTO_PUBLIC_KEY_SIZE,
data + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE,
plain_len + CRYPTO_MAC_SIZE,
@@ -568,7 +567,7 @@ static int create_reply(Announcements *announce, const IP_Port *source,
VLA(uint8_t, plain, plain_len);
const uint8_t *shared_key = dht_get_shared_key_recv(announce->dht, data + 1);
- if (decrypt_data_symmetric(shared_key,
+ if (decrypt_data_symmetric(announce->mem, shared_key,
data + 1 + CRYPTO_PUBLIC_KEY_SIZE,
data + 1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE,
plain_len + CRYPTO_MAC_SIZE,
@@ -579,7 +578,7 @@ static int create_reply(Announcements *announce, const IP_Port *source,
const int plain_reply_max_len = (int)reply_max_length -
(1 + CRYPTO_PUBLIC_KEY_SIZE + CRYPTO_NONCE_SIZE + CRYPTO_MAC_SIZE);
- if (plain_reply_max_len < sizeof(uint64_t)) {
+ if (plain_reply_max_len < (int)sizeof(uint64_t)) {
return -1;
}
@@ -651,7 +650,7 @@ Announcements *new_announcements(const Logger *log, const Memory *mem, const Ran
return nullptr;
}
- Announcements *announce = (Announcements *)calloc(1, sizeof(Announcements));
+ Announcements *announce = (Announcements *)mem_alloc(mem, sizeof(Announcements));
if (announce == nullptr) {
return nullptr;
@@ -669,7 +668,7 @@ Announcements *new_announcements(const Logger *log, const Memory *mem, const Ran
new_hmac_key(announce->rng, announce->hmac_key);
announce->shared_keys = shared_key_cache_new(log, mono_time, mem, announce->secret_key, KEYS_TIMEOUT, MAX_KEYS_PER_SLOT);
if (announce->shared_keys == nullptr) {
- free(announce);
+ mem_delete(announce->mem, announce);
return nullptr;
}
@@ -700,8 +699,8 @@ void kill_announcements(Announcements *announce)
shared_key_cache_free(announce->shared_keys);
for (uint32_t i = 0; i < ANNOUNCE_BUCKETS * ANNOUNCE_BUCKET_SIZE; ++i) {
- free(announce->entries[i].data);
+ mem_delete(announce->mem, announce->entries[i].data);
}
- free(announce);
+ mem_delete(announce->mem, announce);
}