mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
Fix a buffer overflow in cached_esc_sequences_t::find_entry
cached_esc_sequences_t::find_entry was constructing a wcstring from a c string, using lengths longer than the length of the cstring. Detected with asan.
This commit is contained in:
parent
3d6c4adda9
commit
9f13edbe4a
1 changed files with 2 additions and 0 deletions
|
@ -242,7 +242,9 @@ class cached_esc_sequences_t {
|
|||
}
|
||||
|
||||
size_t find_entry(const wchar_t *entry) {
|
||||
size_t entry_len = wcslen(entry);
|
||||
for (auto len : lengths) {
|
||||
if (len > entry_len) continue;
|
||||
auto match = cache.find(wcstring(entry, len));
|
||||
if (match != cache.end()) { // we found a matching cached sequence
|
||||
// Periodically sort the sequence lengths so we check for matches going from the
|
||||
|
|
Loading…
Reference in a new issue