diff options
-rw-r--r-- | toxcore/Messenger.c | 6 | ||||
-rw-r--r-- | toxcore/friend_requests.c | 3 | ||||
-rw-r--r-- | toxcore/tox.h | 3 |
3 files changed, 10 insertions, 2 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c index 3b09baa2..fef2e9e5 100644 --- a/toxcore/Messenger.c +++ b/toxcore/Messenger.c | |||
@@ -821,6 +821,8 @@ static void group_message_function(Group_Chat *chat, int peer_number, uint8_t *m | |||
821 | if (i == -1) | 821 | if (i == -1) |
822 | return; | 822 | return; |
823 | 823 | ||
824 | message[length - 1] = 0; /* Force NULL terminator */ | ||
825 | |||
824 | if (m->group_message) | 826 | if (m->group_message) |
825 | (*m->group_message)(m, i, peer_number, message, length, m->group_message_userdata); | 827 | (*m->group_message)(m, i, peer_number, message, length, m->group_message_userdata); |
826 | } | 828 | } |
@@ -833,6 +835,8 @@ static void group_action_function(Group_Chat *chat, int peer_number, uint8_t *ac | |||
833 | if (i == -1) | 835 | if (i == -1) |
834 | return; | 836 | return; |
835 | 837 | ||
838 | action[length - 1] = 0; /* Force NULL terminator */ | ||
839 | |||
836 | if (m->group_action) | 840 | if (m->group_action) |
837 | (*m->group_action)(m, i, peer_number, action, length, m->group_action_userdata); | 841 | (*m->group_action)(m, i, peer_number, action, length, m->group_action_userdata); |
838 | } | 842 | } |
@@ -1848,6 +1852,8 @@ void do_friends(Messenger *m) | |||
1848 | m->friendlist[i].file_receiving[filenumber].size = filesize; | 1852 | m->friendlist[i].file_receiving[filenumber].size = filesize; |
1849 | m->friendlist[i].file_receiving[filenumber].transferred = 0; | 1853 | m->friendlist[i].file_receiving[filenumber].transferred = 0; |
1850 | 1854 | ||
1855 | data[data_length - 1] = 0; /* Force NULL terminate file name. */ | ||
1856 | |||
1851 | if (m->file_sendrequest) | 1857 | if (m->file_sendrequest) |
1852 | (*m->file_sendrequest)(m, i, filenumber, filesize, data + 1 + sizeof(uint64_t), data_length - 1 - sizeof(uint64_t), | 1858 | (*m->file_sendrequest)(m, i, filenumber, filesize, data + 1 + sizeof(uint64_t), data_length - 1 - sizeof(uint64_t), |
1853 | m->file_sendrequest_userdata); | 1859 | m->file_sendrequest_userdata); |
diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c index 5c294c76..9ac72097 100644 --- a/toxcore/friend_requests.c +++ b/toxcore/friend_requests.c | |||
@@ -140,6 +140,9 @@ static int friendreq_handlepacket(void *object, uint8_t *source_pubkey, uint8_t | |||
140 | return 1; | 140 | return 1; |
141 | 141 | ||
142 | addto_receivedlist(fr, source_pubkey); | 142 | addto_receivedlist(fr, source_pubkey); |
143 | |||
144 | packet[length - 1] = 0; /* Force NULL terminator. */ | ||
145 | |||
143 | (*fr->handle_friendrequest)(source_pubkey, packet + 4, length - 4, fr->handle_friendrequest_userdata); | 146 | (*fr->handle_friendrequest)(source_pubkey, packet + 4, length - 4, fr->handle_friendrequest_userdata); |
144 | return 0; | 147 | return 0; |
145 | } | 148 | } |
diff --git a/toxcore/tox.h b/toxcore/tox.h index 75e1a303..447a1146 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -132,8 +132,7 @@ typedef struct Tox Tox; | |||
132 | * | 132 | * |
133 | * The length when passing those strings to the core includes that NULL character. | 133 | * The length when passing those strings to the core includes that NULL character. |
134 | * | 134 | * |
135 | * It wont do anything if you send you send non NULL terminated strings because Tox force NULL terminates them anyways | 135 | * If you send non NULL terminated strings Tox will force NULL terminates them when it receives them. |
136 | * when it receives them. | ||
137 | */ | 136 | */ |
138 | 137 | ||
139 | /* return TOX_FRIEND_ADDRESS_SIZE byte address to give to others. | 138 | /* return TOX_FRIEND_ADDRESS_SIZE byte address to give to others. |