mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-14 22:36: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)
|
- DNS setting with `IPAddress4/5` not persisted (#23426)
|
||||||
- Berry avoid json parsing for unmatched commands
|
- Berry avoid json parsing for unmatched commands
|
||||||
- Berry fix integer and real parser to handle overflows
|
- Berry fix integer and real parser to handle overflows
|
||||||
|
- Berry fix potential pointer underflow with `string.endswith`
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
@ -1074,14 +1074,17 @@ static int str_endswith(bvm *vm)
|
|||||||
bbool result = bfalse;
|
bbool result = bfalse;
|
||||||
const char *s = be_tostring(vm, 1);
|
const char *s = be_tostring(vm, 1);
|
||||||
const char *p = be_tostring(vm, 2);
|
const char *p = be_tostring(vm, 2);
|
||||||
size_t len = (size_t)be_strlen(vm, 2);
|
size_t len_s = (size_t)be_strlen(vm, 1);
|
||||||
if (case_insensitive) {
|
size_t len_p = (size_t)be_strlen(vm, 2);
|
||||||
if (str_strncasecmp(s + (int)strlen(s) - (int)len, p, len) == 0) {
|
if (len_s >= len_p) {
|
||||||
result = btrue;
|
if (case_insensitive) {
|
||||||
}
|
if (str_strncasecmp(s + (int)len_s - (int)len_p, p, len_p) == 0) {
|
||||||
} else {
|
result = btrue;
|
||||||
if (strncmp(s + (int)strlen(s) - (int)len, p, len) == 0) {
|
}
|
||||||
result = btrue;
|
} else {
|
||||||
|
if (strncmp(s + (int)len_s - (int)len_p, p, len_p) == 0) {
|
||||||
|
result = btrue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
be_pushbool(vm, result);
|
be_pushbool(vm, result);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user