mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-09 20:06:31 +00:00
Berry fix potential pointer underflow with string.endswith
(#23496)
This commit is contained in:
parent
1cd4e27123
commit
ea9a24e76d
@ -29,6 +29,7 @@ All notable changes to this project will be documented in this file.
|
||||
- DNS setting with `IPAddress4/5` not persisted (#23426)
|
||||
- Berry avoid json parsing for unmatched commands
|
||||
- Berry fix integer and real parser to handle overflows
|
||||
- Berry fix potential pointer underflow with `string.endswith`
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -1074,14 +1074,17 @@ static int str_endswith(bvm *vm)
|
||||
bbool result = bfalse;
|
||||
const char *s = be_tostring(vm, 1);
|
||||
const char *p = be_tostring(vm, 2);
|
||||
size_t len = (size_t)be_strlen(vm, 2);
|
||||
if (case_insensitive) {
|
||||
if (str_strncasecmp(s + (int)strlen(s) - (int)len, p, len) == 0) {
|
||||
result = btrue;
|
||||
}
|
||||
} else {
|
||||
if (strncmp(s + (int)strlen(s) - (int)len, p, len) == 0) {
|
||||
result = btrue;
|
||||
size_t len_s = (size_t)be_strlen(vm, 1);
|
||||
size_t len_p = (size_t)be_strlen(vm, 2);
|
||||
if (len_s >= len_p) {
|
||||
if (case_insensitive) {
|
||||
if (str_strncasecmp(s + (int)len_s - (int)len_p, p, len_p) == 0) {
|
||||
result = btrue;
|
||||
}
|
||||
} else {
|
||||
if (strncmp(s + (int)len_s - (int)len_p, p, len_p) == 0) {
|
||||
result = btrue;
|
||||
}
|
||||
}
|
||||
}
|
||||
be_pushbool(vm, result);
|
||||
|
Loading…
x
Reference in New Issue
Block a user