Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set SAVED_FRIEND to always have 8-byte alignment. #279

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions toxcore/Messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -2633,19 +2633,27 @@ void do_messenger(Messenger *m, void *userdata)

#define SAVED_FRIEND_REQUEST_SIZE 1024
#define NUM_SAVED_PATH_NODES 8

struct SAVED_FRIEND {
uint8_t status;
uint8_t real_pk[crypto_box_PUBLICKEYBYTES];
uint8_t info[SAVED_FRIEND_REQUEST_SIZE]; // the data that is sent during the friend requests we do.
uint8_t info[SAVED_FRIEND_REQUEST_SIZE];
// ^ The data sent during the friend requests we do.
uint8_t : 8; // padding
uint16_t info_size; // Length of the info.
uint8_t name[MAX_NAME_LENGTH];
uint16_t name_length;
uint8_t statusmessage[MAX_STATUSMESSAGE_LENGTH];
uint8_t : 8; // padding
uint16_t statusmessage_length;
uint8_t userstatus;
uint8_t : 8; // padding
uint16_t : 16; // padding
uint32_t friendrequest_nospam;
uint64_t last_seen_time;
};
} __attribute__ ((aligned (8)));
// __attribute__ ((aligned (8))) *shouldn't* do anything, as everything's
// manually aligned to 8-byte boundaries but left it in to be on the safe side.

static uint32_t saved_friendslist_size(const Messenger *m)
{
Expand Down