forked from Green-Sky/tomato
Squashed 'external/toxcore/c-toxcore/' changes from 82460b2124..38e4c82fe0
38e4c82fe0 feat: add ngc events 8099d82397 diagnostic: get the number of close dht nodes with announce/store support d01c116764 cleanup: make it more clear that assert and uint32_t increment both only exist if NDEBUG is not defined 58fac53429 refactor: Add a `bin_unpack_bin_max` for max-length arrays. 6be29f01e5 chore: Add more logging to loading conferences from savedata. 1195271b7f Fix inversed return values 82276ef5ac cleanup: Fix GCC compatibility. REVERT: 82460b2124 feat: add ngc events git-subtree-dir: external/toxcore/c-toxcore git-subtree-split: 38e4c82fe0fc373b9d43ee9ad2b8fe5fd1d26810
This commit is contained in:
@ -22,7 +22,7 @@
|
||||
non_null()
|
||||
static bool load_unpack_state_values(GC_Chat *chat, Bin_Unpack *bu)
|
||||
{
|
||||
if (!bin_unpack_array_fixed(bu, 8)) {
|
||||
if (!bin_unpack_array_fixed(bu, 8, nullptr)) {
|
||||
LOGGER_ERROR(chat->log, "Group state values array malformed");
|
||||
return false;
|
||||
}
|
||||
@ -58,15 +58,23 @@ static bool load_unpack_state_values(GC_Chat *chat, Bin_Unpack *bu)
|
||||
non_null()
|
||||
static bool load_unpack_state_bin(GC_Chat *chat, Bin_Unpack *bu)
|
||||
{
|
||||
if (!bin_unpack_array_fixed(bu, 5)) {
|
||||
if (!bin_unpack_array_fixed(bu, 5, nullptr)) {
|
||||
LOGGER_ERROR(chat->log, "Group state binary array malformed");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(bin_unpack_bin_fixed(bu, chat->shared_state_sig, SIGNATURE_SIZE)
|
||||
&& bin_unpack_bin_fixed(bu, chat->shared_state.founder_public_key, EXT_PUBLIC_KEY_SIZE)
|
||||
&& bin_unpack_bin_fixed(bu, chat->shared_state.group_name, chat->shared_state.group_name_len)
|
||||
&& bin_unpack_bin_fixed(bu, chat->shared_state.password, chat->shared_state.password_length)
|
||||
if (!bin_unpack_bin_fixed(bu, chat->shared_state_sig, SIGNATURE_SIZE)) {
|
||||
LOGGER_ERROR(chat->log, "Failed to unpack shared state signature");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!bin_unpack_bin_fixed(bu, chat->shared_state.founder_public_key, EXT_PUBLIC_KEY_SIZE)) {
|
||||
LOGGER_ERROR(chat->log, "Failed to unpack founder public key");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(bin_unpack_bin_max(bu, chat->shared_state.group_name, &chat->shared_state.group_name_len, sizeof(chat->shared_state.group_name))
|
||||
&& bin_unpack_bin_max(bu, chat->shared_state.password, &chat->shared_state.password_length, sizeof(chat->shared_state.password))
|
||||
&& bin_unpack_bin_fixed(bu, chat->shared_state.mod_list_hash, MOD_MODERATION_HASH_SIZE))) {
|
||||
LOGGER_ERROR(chat->log, "Failed to unpack state binary data");
|
||||
return false;
|
||||
@ -78,7 +86,7 @@ static bool load_unpack_state_bin(GC_Chat *chat, Bin_Unpack *bu)
|
||||
non_null()
|
||||
static bool load_unpack_topic_info(GC_Chat *chat, Bin_Unpack *bu)
|
||||
{
|
||||
if (!bin_unpack_array_fixed(bu, 6)) {
|
||||
if (!bin_unpack_array_fixed(bu, 6, nullptr)) {
|
||||
LOGGER_ERROR(chat->log, "Group topic array malformed");
|
||||
return false;
|
||||
}
|
||||
@ -86,7 +94,7 @@ static bool load_unpack_topic_info(GC_Chat *chat, Bin_Unpack *bu)
|
||||
if (!(bin_unpack_u32(bu, &chat->topic_info.version)
|
||||
&& bin_unpack_u16(bu, &chat->topic_info.length)
|
||||
&& bin_unpack_u16(bu, &chat->topic_info.checksum)
|
||||
&& bin_unpack_bin_fixed(bu, chat->topic_info.topic, chat->topic_info.length)
|
||||
&& bin_unpack_bin_max(bu, chat->topic_info.topic, &chat->topic_info.length, sizeof(chat->topic_info.topic))
|
||||
&& bin_unpack_bin_fixed(bu, chat->topic_info.public_sig_key, SIG_PUBLIC_KEY_SIZE)
|
||||
&& bin_unpack_bin_fixed(bu, chat->topic_sig, SIGNATURE_SIZE))) {
|
||||
LOGGER_ERROR(chat->log, "Failed to unpack topic info");
|
||||
@ -99,8 +107,9 @@ static bool load_unpack_topic_info(GC_Chat *chat, Bin_Unpack *bu)
|
||||
non_null()
|
||||
static bool load_unpack_mod_list(GC_Chat *chat, Bin_Unpack *bu)
|
||||
{
|
||||
if (!bin_unpack_array_fixed(bu, 2)) {
|
||||
LOGGER_ERROR(chat->log, "Group mod list array malformed");
|
||||
uint32_t actual_size = 0;
|
||||
if (!bin_unpack_array_fixed(bu, 2, &actual_size)) {
|
||||
LOGGER_ERROR(chat->log, "Group mod list array malformed: %d != 2", actual_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -148,7 +157,7 @@ static bool load_unpack_mod_list(GC_Chat *chat, Bin_Unpack *bu)
|
||||
non_null()
|
||||
static bool load_unpack_keys(GC_Chat *chat, Bin_Unpack *bu)
|
||||
{
|
||||
if (!bin_unpack_array_fixed(bu, 4)) {
|
||||
if (!bin_unpack_array_fixed(bu, 4, nullptr)) {
|
||||
LOGGER_ERROR(chat->log, "Group keys array malformed");
|
||||
return false;
|
||||
}
|
||||
@ -167,7 +176,7 @@ static bool load_unpack_keys(GC_Chat *chat, Bin_Unpack *bu)
|
||||
non_null()
|
||||
static bool load_unpack_self_info(GC_Chat *chat, Bin_Unpack *bu)
|
||||
{
|
||||
if (!bin_unpack_array_fixed(bu, 4)) {
|
||||
if (!bin_unpack_array_fixed(bu, 4, nullptr)) {
|
||||
LOGGER_ERROR(chat->log, "Group self info array malformed");
|
||||
return false;
|
||||
}
|
||||
@ -214,7 +223,7 @@ static bool load_unpack_self_info(GC_Chat *chat, Bin_Unpack *bu)
|
||||
non_null()
|
||||
static bool load_unpack_saved_peers(GC_Chat *chat, Bin_Unpack *bu)
|
||||
{
|
||||
if (!bin_unpack_array_fixed(bu, 2)) {
|
||||
if (!bin_unpack_array_fixed(bu, 2, nullptr)) {
|
||||
LOGGER_ERROR(chat->log, "Group saved peers array malformed");
|
||||
return false;
|
||||
}
|
||||
@ -256,8 +265,9 @@ static bool load_unpack_saved_peers(GC_Chat *chat, Bin_Unpack *bu)
|
||||
|
||||
bool gc_load_unpack_group(GC_Chat *chat, Bin_Unpack *bu)
|
||||
{
|
||||
if (!bin_unpack_array_fixed(bu, 7)) {
|
||||
LOGGER_ERROR(chat->log, "Group info array malformed");
|
||||
uint32_t actual_size;
|
||||
if (!bin_unpack_array_fixed(bu, 7, &actual_size)) {
|
||||
LOGGER_ERROR(chat->log, "Group info array malformed: %d != 7", actual_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user