From: paulhsia Date: Fri, 29 Nov 2019 19:35:30 +0000 (+0800) Subject: ucm: Use strncmp to avoid access-out-of-boundary X-Git-Tag: v1.2.2~78 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=c79f09e1f5e8b559b58dacdb00708d995b2e3aa5;p=alsa-lib.git 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 Signed-off-by: Jaroslav Kysela --- diff --git a/src/ucm/main.c b/src/ucm/main.c index b0b6ffb3..252e50d9 100644 --- a/src/ucm/main.c +++ b/src/ucm/main.c @@ -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; }