summaryrefslogtreecommitdiff
path: root/toxcore/Messenger.c
diff options
context:
space:
mode:
authorCoren[m] <Break@Ocean>2013-11-11 15:25:43 +0100
committerCoren[m] <Break@Ocean>2013-11-11 15:25:54 +0100
commit553aba04987c230dcbed0aa805c77d04e28eedcf (patch)
treee99696f5f115ce74cc670e9540fd7526741f2975 /toxcore/Messenger.c
parent4993928888ccec0b2c894d695e9f4736b63d6a80 (diff)
nTox.c:
- multiple places: tox_getname() doesn't terminate the string, make sure nTox does - format_message(): . - renamed to print_formatted_message() . - changed semantics: does the new_line() itself, saves caller from freeing the buffer (which no caller did) . - changed signature: now also prints the friend's name when sending . - intern: date is only printed once, the message line gets only time - print_message(): enforce null termination - main(): . - setlocale() to init locale (for date/time printing) . - own name: ensure null termination Messenger.c: - notify of friend name change *before* the old name is overwritten
Diffstat (limited to 'toxcore/Messenger.c')
-rw-r--r--toxcore/Messenger.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/toxcore/Messenger.c b/toxcore/Messenger.c
index 659c837b..66faa4db 100644
--- a/toxcore/Messenger.c
+++ b/toxcore/Messenger.c
@@ -1539,12 +1539,15 @@ void do_friends(Messenger *m)
1539 if (data_length >= MAX_NAME_LENGTH || data_length == 0) 1539 if (data_length >= MAX_NAME_LENGTH || data_length == 0)
1540 break; 1540 break;
1541 1541
1542 memcpy(m->friendlist[i].name, data, data_length); 1542 /* Make sure the NULL terminator is present. */
1543 m->friendlist[i].name_length = data_length; 1543 data[data_length - 1] = 0;
1544 m->friendlist[i].name[data_length - 1] = 0; /* Make sure the NULL terminator is present. */
1545 1544
1545 /* inform of namechange before we overwrite the old name */
1546 if (m->friend_namechange) 1546 if (m->friend_namechange)
1547 m->friend_namechange(m, i, m->friendlist[i].name, data_length, m->friend_namechange_userdata); 1547 m->friend_namechange(m, i, data, data_length, m->friend_namechange_userdata);
1548
1549 memcpy(m->friendlist[i].name, data, data_length);
1550 m->friendlist[i].name_length = data_length;
1548 1551
1549 break; 1552 break;
1550 } 1553 }