mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
All strings should now be forced terminated when received.
This commit is contained in:
parent
95dd3dfdde
commit
704c27c66c
|
@ -821,6 +821,8 @@ static void group_message_function(Group_Chat *chat, int peer_number, uint8_t *m
|
|||
if (i == -1)
|
||||
return;
|
||||
|
||||
message[length - 1] = 0; /* Force NULL terminator */
|
||||
|
||||
if (m->group_message)
|
||||
(*m->group_message)(m, i, peer_number, message, length, m->group_message_userdata);
|
||||
}
|
||||
|
@ -833,6 +835,8 @@ static void group_action_function(Group_Chat *chat, int peer_number, uint8_t *ac
|
|||
if (i == -1)
|
||||
return;
|
||||
|
||||
action[length - 1] = 0; /* Force NULL terminator */
|
||||
|
||||
if (m->group_action)
|
||||
(*m->group_action)(m, i, peer_number, action, length, m->group_action_userdata);
|
||||
}
|
||||
|
@ -1848,6 +1852,8 @@ void do_friends(Messenger *m)
|
|||
m->friendlist[i].file_receiving[filenumber].size = filesize;
|
||||
m->friendlist[i].file_receiving[filenumber].transferred = 0;
|
||||
|
||||
data[data_length - 1] = 0; /* Force NULL terminate file name. */
|
||||
|
||||
if (m->file_sendrequest)
|
||||
(*m->file_sendrequest)(m, i, filenumber, filesize, data + 1 + sizeof(uint64_t), data_length - 1 - sizeof(uint64_t),
|
||||
m->file_sendrequest_userdata);
|
||||
|
|
|
@ -140,6 +140,9 @@ static int friendreq_handlepacket(void *object, uint8_t *source_pubkey, uint8_t
|
|||
return 1;
|
||||
|
||||
addto_receivedlist(fr, source_pubkey);
|
||||
|
||||
packet[length - 1] = 0; /* Force NULL terminator. */
|
||||
|
||||
(*fr->handle_friendrequest)(source_pubkey, packet + 4, length - 4, fr->handle_friendrequest_userdata);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -132,8 +132,7 @@ typedef struct Tox Tox;
|
|||
*
|
||||
* The length when passing those strings to the core includes that NULL character.
|
||||
*
|
||||
* It wont do anything if you send you send non NULL terminated strings because Tox force NULL terminates them anyways
|
||||
* when it receives them.
|
||||
* If you send non NULL terminated strings Tox will force NULL terminates them when it receives them.
|
||||
*/
|
||||
|
||||
/* return TOX_FRIEND_ADDRESS_SIZE byte address to give to others.
|
||||
|
|
Loading…
Reference in New Issue
Block a user