From 3bc42e45387e70bbcac8cea26cb082283abc7c22 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sun, 2 Jun 2024 11:53:51 +0200 Subject: [PATCH] chores: update LZ4 (#5102) --- .../src/thirdparty/libopenui/thirdparty/lz4/lz4.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/radio/src/thirdparty/libopenui/thirdparty/lz4/lz4.c b/radio/src/thirdparty/libopenui/thirdparty/lz4/lz4.c index e64d3c2e5..4653b34eb 100644 --- a/radio/src/thirdparty/libopenui/thirdparty/lz4/lz4.c +++ b/radio/src/thirdparty/libopenui/thirdparty/lz4/lz4.c @@ -1931,6 +1931,17 @@ read_variable_length(const BYTE** ip, const BYTE* ilimit, if (initial_check && unlikely((*ip) >= ilimit)) { /* read limit reached */ return rvl_error; } + s = **ip; + (*ip)++; + length += s; + if (unlikely((*ip) > ilimit)) { /* read limit reached */ + return rvl_error; + } + /* accumulator overflow detection (32-bit mode only) */ + if ((sizeof(length) < 8) && unlikely(length > ((Rvl_t)(-1)/2)) ) { + return rvl_error; + } + if (likely(s != 255)) return length; do { s = **ip; (*ip)++; @@ -1939,10 +1950,10 @@ read_variable_length(const BYTE** ip, const BYTE* ilimit, return rvl_error; } /* accumulator overflow detection (32-bit mode only) */ - if ((sizeof(length)<8) && unlikely(length > ((Rvl_t)(-1)/2)) ) { + if ((sizeof(length) < 8) && unlikely(length > ((Rvl_t)(-1)/2)) ) { return rvl_error; } - } while (s==255); + } while (s == 255); return length; }