1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-27 03:03:26 +01:00

endian correctness

This commit is contained in:
Jfreegman 2014-07-31 15:02:19 -04:00
parent 5da789cc37
commit af68fa7ee0
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63

View File

@ -24,6 +24,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <arpa/inet.h>
#include <tox/tox.h> #include <tox/tox.h>
@ -95,7 +96,7 @@ static int save_blocklist(char *path)
if (Blocked_Contacts.list[i].active) { if (Blocked_Contacts.list[i].active) {
BlockedFriend tmp; BlockedFriend tmp;
memset(&tmp, 0, sizeof(BlockedFriend)); memset(&tmp, 0, sizeof(BlockedFriend));
tmp.namelength = Blocked_Contacts.list[i].namelength; tmp.namelength = htons(Blocked_Contacts.list[i].namelength);
memcpy(tmp.name, Blocked_Contacts.list[i].name, Blocked_Contacts.list[i].namelength + 1); memcpy(tmp.name, Blocked_Contacts.list[i].name, Blocked_Contacts.list[i].namelength + 1);
memcpy(tmp.pub_key, Blocked_Contacts.list[i].pub_key, TOX_CLIENT_ID_SIZE); memcpy(tmp.pub_key, Blocked_Contacts.list[i].pub_key, TOX_CLIENT_ID_SIZE);
@ -169,8 +170,8 @@ int load_blocklist(char *path)
memcpy(&tmp, data + i * sizeof(BlockedFriend), sizeof(BlockedFriend)); memcpy(&tmp, data + i * sizeof(BlockedFriend), sizeof(BlockedFriend));
Blocked_Contacts.list[i].active = true; Blocked_Contacts.list[i].active = true;
Blocked_Contacts.list[i].num = i; Blocked_Contacts.list[i].num = i;
Blocked_Contacts.list[i].namelength = tmp.namelength; Blocked_Contacts.list[i].namelength = ntohs(tmp.namelength);
memcpy(Blocked_Contacts.list[i].name, tmp.name, tmp.namelength + 1); memcpy(Blocked_Contacts.list[i].name, tmp.name, Blocked_Contacts.list[i].namelength + 1);
memcpy(Blocked_Contacts.list[i].pub_key, tmp.pub_key, TOX_CLIENT_ID_SIZE); memcpy(Blocked_Contacts.list[i].pub_key, tmp.pub_key, TOX_CLIENT_ID_SIZE);
uint8_t lastonline[sizeof(uint64_t)]; uint8_t lastonline[sizeof(uint64_t)];