mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-01 22:58:49 -04:00
ucm: Use strncmp to avoid access-out-of-boundary
If the length of the identifier is less than the length of the prefix, access-out-of-boundary will occur in memcmp(). Signed-off-by: paulhsia <paulhsia@chromium.org> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
1c7e46d5d8
commit
c79f09e1f5
1 changed files with 5 additions and 3 deletions
|
|
@ -61,11 +61,13 @@ static int check_identifier(const char *identifier, const char *prefix)
|
|||
{
|
||||
int len;
|
||||
|
||||
if (strcmp(identifier, prefix) == 0)
|
||||
return 1;
|
||||
len = strlen(prefix);
|
||||
if (memcmp(identifier, prefix, len) == 0 && identifier[len] == '/')
|
||||
if (strncmp(identifier, prefix, len) != 0)
|
||||
return 0;
|
||||
|
||||
if (identifier[len] == 0 || identifier[len] == '/')
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue