mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
check length of name
This commit is contained in:
parent
c4702985a5
commit
23e03b0ba9
|
@ -357,6 +357,9 @@ int setfriendname(Messenger *m, int friendnumber, uint8_t *name, uint16_t length
|
||||||
if (friend_not_valid(m, friendnumber))
|
if (friend_not_valid(m, friendnumber))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (length > MAX_NAME_LENGTH || length == 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
m->friendlist[friendnumber].name_length = length;
|
m->friendlist[friendnumber].name_length = length;
|
||||||
memcpy(m->friendlist[friendnumber].name, name, length);
|
memcpy(m->friendlist[friendnumber].name, name, length);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -247,6 +247,9 @@ uint32_t m_sendmessage_withid(Messenger *m, int friendnumber, uint32_t theid, ui
|
||||||
int m_sendaction(Messenger *m, int friendnumber, uint8_t *action, uint32_t length);
|
int m_sendaction(Messenger *m, int friendnumber, uint8_t *action, uint32_t length);
|
||||||
|
|
||||||
/* Set the name and name_length of a friend.
|
/* Set the name and name_length of a friend.
|
||||||
|
* name must be a string of maximum MAX_NAME_LENGTH length.
|
||||||
|
* length must be at least 1 byte.
|
||||||
|
* length is the length of name with the NULL terminator.
|
||||||
*
|
*
|
||||||
* return 0 if success.
|
* return 0 if success.
|
||||||
* return -1 if failure.
|
* return -1 if failure.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user