mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-27 21:37:37 -04:00
module-avb: SET_NAME: check that string is valid utf8 and zero padded
This commit is contained in:
parent
14b1c4d3dd
commit
ef77d995cd
1 changed files with 9 additions and 7 deletions
|
|
@ -146,7 +146,6 @@ int handle_cmd_get_name_common(struct aecp *aecp, int64_t now,
|
|||
|
||||
/**
|
||||
* IEEE 1722.1-2021 7.4.17 SET_NAME
|
||||
* For now this is not handling UTF characters, only ASCII
|
||||
*/
|
||||
int handle_cmd_set_name_common(struct aecp *aecp, int64_t now,
|
||||
const void *m, int len)
|
||||
|
|
@ -182,14 +181,17 @@ int handle_cmd_set_name_common(struct aecp *aecp, int64_t now,
|
|||
/**
|
||||
* IEEE 1722.1-2021: 7.4.17.1: The name does not contain a trailing NULL
|
||||
* but if the name is less than 64 bytes in length then it is zero
|
||||
* padded
|
||||
* padded.
|
||||
*/
|
||||
memcpy(name_ptr, cmd->name, 64);
|
||||
if (check_zero_padding(cmd->name, 64) == -1)
|
||||
return reply_status(aecp,
|
||||
AVB_AECP_AEM_STATUS_BAD_ARGUMENTS, m, len);
|
||||
|
||||
/** TODO: According to the specification, the string should alwasy be 0
|
||||
* terminated, the goal would be to check whether a string is UTF-8 and
|
||||
* that it is correctly zero terminitaed if less than 64 char, if not
|
||||
* then a simple memcpy is enough */
|
||||
if (validate_utf8(cmd->name, 64) == -1)
|
||||
return reply_status(aecp,
|
||||
AVB_AECP_AEM_STATUS_BAD_ARGUMENTS, m, len);
|
||||
|
||||
memcpy(name_ptr, cmd->name, 64);
|
||||
|
||||
rc = reply_success(aecp, m, len);
|
||||
if (rc < 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue