Samples: Bluetooth: Fix bug in is_substring for broadcast sink

The is_substring did not work for true substrings, as it
would always compare [0] to [0], so it would return false
for the substring "BC" being in "ABC".

Removed the tolower as it is not necessary and fixes the issue.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2023-12-04 13:07:36 +01:00 committed by Carles Cufí
commit e54902bdbe

View file

@ -618,14 +618,12 @@ static bool is_substring(const char *substr, const char *str)
}
for (size_t pos = 0; pos < str_len; pos++) {
if (tolower(substr[pos]) == tolower(str[pos])) {
if (pos + sub_str_len > str_len) {
return false;
}
if (pos + sub_str_len > str_len) {
return false;
}
if (strncasecmp(substr, &str[pos], sub_str_len) == 0) {
return true;
}
if (strncasecmp(substr, &str[pos], sub_str_len) == 0) {
return true;
}
}