From 5a904c64dcdf6220fd38497ef0d121dee00ebb77 Mon Sep 17 00:00:00 2001 From: rigaya Date: Sat, 24 Jun 2023 08:48:15 +0900 Subject: [PATCH] =?UTF-8?q?faw=E5=87=A6=E7=90=86=E6=99=82=E3=81=AB?= =?UTF-8?q?=E9=9F=B3=E5=A3=B0=E3=81=8C=E3=83=96=E3=83=84=E3=83=96=E3=83=84?= =?UTF-8?q?=E5=88=87=E3=82=8C=E3=82=8B=E5=A0=B4=E5=90=88=E3=81=8C=E3=81=82?= =?UTF-8?q?=E3=81=A3=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VCECore/rgy_faw.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/VCECore/rgy_faw.cpp b/VCECore/rgy_faw.cpp index 3ab188d6..04aa1298 100644 --- a/VCECore/rgy_faw.cpp +++ b/VCECore/rgy_faw.cpp @@ -120,11 +120,17 @@ void faw_read(uint8_t *dst, const uint8_t *src, const size_t outlen) { static uint32_t faw_checksum_calc(const uint8_t *buf, const size_t len) { uint32_t _v4288 = 0; uint32_t _v48 = 0; - for (size_t i = 0; i < len; i += 2) { + const size_t fin_mod2 = (len & (~1)); + for (size_t i = 0; i < fin_mod2; i += 2) { uint32_t _v132 = *(uint16_t *)(buf + i); _v4288 += _v132; _v48 ^= _v132; } + if ((len & 1) != 0) { + uint32_t _v132 = *(uint8_t *)(buf + len - 1); + _v4288 += _v132; + _v48 ^= _v132; + } uint32_t res = (_v4288 & 0xffff) | ((_v48 & 0xffff) << 16); return res; }