From a0747212b619391b1b86d505753986823e47518b Mon Sep 17 00:00:00 2001 From: Andrei Popa Date: Fri, 10 May 2024 13:24:11 +0300 Subject: [PATCH] plugins: adrv9002: API version validation fix - validation failed if driver was "68.8.1" and profile gen was "v68.8.1" Signed-off-by: Andrei Popa --- plugins/adrv9002.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/plugins/adrv9002.c b/plugins/adrv9002.c index 7969b569..6aea18dd 100644 --- a/plugins/adrv9002.c +++ b/plugins/adrv9002.c @@ -2263,6 +2263,25 @@ static char *profile_gen_cli_get_api(void) return version; } +static char *strip_leading_and_trailing_nonnumeric_chars(char *string) +{ + int i; + char *str = (char *)malloc(strlen(string) * sizeof(char)); + sprintf(str, "%s", string); + + while((str[0] < '0' || str[0] > '9') && str[0] != '\0') { + str++; + } + + i = strlen(str) - 1; + while((str[i] < '0' || str[i] > '9') && i > 0) { + str[i] = '\0'; + i--; + } + + return str; +} + static bool profile_gen_check_api(gpointer data) { struct plugin_private *priv = data; @@ -2281,7 +2300,8 @@ static bool profile_gen_check_api(gpointer data) goto err; } - if(strcmp(version, supported_version) != 0) { + if(strcmp(strip_leading_and_trailing_nonnumeric_chars(supported_version), + strip_leading_and_trailing_nonnumeric_chars(version)) != 0) { sprintf(message, "\nOnly API version %s is supported, the device uses %s!", supported_version, version); profile_gen_set_debug_info(data, message); free(supported_version);