1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-03 21:06:46 +02:00

Cleanup code around tox ID/pk conversion functions

This commit is contained in:
jfreegman
2021-12-06 10:46:19 -05:00
parent afbd185222
commit e2c8497da9
6 changed files with 60 additions and 29 deletions

View File

@ -132,8 +132,10 @@ static int load_nameserver_list(const char *path)
continue;
}
snprintf(Nameservers.names[Nameservers.lines], sizeof(Nameservers.names[Nameservers.lines]), "%s", name);
int res = hex_string_to_bytes(Nameservers.keys[Nameservers.lines], SERVER_KEY_SIZE, keystr);
const size_t idx = Nameservers.lines;
snprintf(Nameservers.names[idx], sizeof(Nameservers.names[idx]), "%s", name);
int res = hex_string_to_bytes(Nameservers.keys[idx], SERVER_KEY_SIZE, keystr);
if (res == -1) {
continue;
@ -231,7 +233,7 @@ static int process_response(struct Recv_Curl_Data *recv_data)
memcpy(ID_string, IDstart + prefix_size, TOX_ADDRESS_SIZE * 2);
ID_string[TOX_ADDRESS_SIZE * 2] = 0;
if (hex_string_to_bin(ID_string, strlen(ID_string), t_data.id_bin, sizeof(t_data.id_bin)) == -1) {
if (tox_pk_string_to_bytes(ID_string, strlen(ID_string), t_data.id_bin, sizeof(t_data.id_bin)) == -1) {
return -1;
}