diff options
author | irungentoo <irungentoo@gmail.com> | 2014-02-23 10:23:55 -0500 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2014-02-23 10:23:55 -0500 |
commit | f3becc62e84bb7c29b5d366523abdab6eeee8a31 (patch) | |
tree | ba9067dfdfd92d8fc158412aa57c4776234337b7 /toxcore/friend_requests.c | |
parent | 50d2b45541923ecd6c911a2acb6288c7632cc8e7 (diff) |
Strings now no longer need to be NULL terminated.
Diffstat (limited to 'toxcore/friend_requests.c')
-rw-r--r-- | toxcore/friend_requests.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/toxcore/friend_requests.c b/toxcore/friend_requests.c index 9ac72097..987b1a4a 100644 --- a/toxcore/friend_requests.c +++ b/toxcore/friend_requests.c | |||
@@ -141,9 +141,11 @@ static int friendreq_handlepacket(void *object, uint8_t *source_pubkey, uint8_t | |||
141 | 141 | ||
142 | addto_receivedlist(fr, source_pubkey); | 142 | addto_receivedlist(fr, source_pubkey); |
143 | 143 | ||
144 | packet[length - 1] = 0; /* Force NULL terminator. */ | 144 | uint8_t message[length - 4 + 1]; |
145 | memcpy(message, packet + 4, length - 4); | ||
146 | message[sizeof(message) - 1] = 0; /* Be sure the message is null terminated. */ | ||
145 | 147 | ||
146 | (*fr->handle_friendrequest)(source_pubkey, packet + 4, length - 4, fr->handle_friendrequest_userdata); | 148 | (*fr->handle_friendrequest)(source_pubkey, message, length - 4, fr->handle_friendrequest_userdata); |
147 | return 0; | 149 | return 0; |
148 | } | 150 | } |
149 | 151 | ||