summaryrefslogtreecommitdiff
path: root/toxcore/friend_requests.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxcore/friend_requests.c')
-rw-r--r--toxcore/friend_requests.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c
index 9ac72097..7574a881 100644
--- a/toxcore/friend_requests.c
+++ b/toxcore/friend_requests.c
@@ -72,11 +72,12 @@ uint32_t get_nospam(Friend_Requests *fr)
72 72
73 73
74/* Set the function that will be executed when a friend request is received. */ 74/* Set the function that will be executed when a friend request is received. */
75void callback_friendrequest(Friend_Requests *fr, void (*function)(uint8_t *, uint8_t *, uint16_t, void *), 75void callback_friendrequest(Friend_Requests *fr, void (*function)(void *, uint8_t *, uint8_t *, uint16_t, void *),
76 void *userdata) 76 void *object, void *userdata)
77{ 77{
78 fr->handle_friendrequest = function; 78 fr->handle_friendrequest = function;
79 fr->handle_friendrequest_isset = 1; 79 fr->handle_friendrequest_isset = 1;
80 fr->handle_friendrequest_object = object;
80 fr->handle_friendrequest_userdata = userdata; 81 fr->handle_friendrequest_userdata = userdata;
81} 82}
82/* Set the function used to check if a friend request should be displayed to the user or not. */ 83/* Set the function used to check if a friend request should be displayed to the user or not. */
@@ -141,9 +142,12 @@ static int friendreq_handlepacket(void *object, uint8_t *source_pubkey, uint8_t
141 142
142 addto_receivedlist(fr, source_pubkey); 143 addto_receivedlist(fr, source_pubkey);
143 144
144 packet[length - 1] = 0; /* Force NULL terminator. */ 145 uint8_t message[length - 4 + 1];
146 memcpy(message, packet + 4, length - 4);
147 message[sizeof(message) - 1] = 0; /* Be sure the message is null terminated. */
145 148
146 (*fr->handle_friendrequest)(source_pubkey, packet + 4, length - 4, fr->handle_friendrequest_userdata); 149 (*fr->handle_friendrequest)(fr->handle_friendrequest_object, source_pubkey, message, length - 4,
150 fr->handle_friendrequest_userdata);
147 return 0; 151 return 0;
148} 152}
149 153