From ff7658c856696e53269a056975242a2f54355618 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Thu, 26 Dec 2019 14:01:58 +0100 Subject: [PATCH] Fix a read-past-end in the LZ4 code. --- patches/lz4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/patches/lz4 b/patches/lz4 index 3013251..5ba8f76 100644 --- a/patches/lz4 +++ b/patches/lz4 @@ -42,11 +42,11 @@ apply "8002faac: \ addiu a1, a1, 1 ; \ # (delay slot) Increment output. beq a0, s0, done ; \ # If we're at the end of the input, skip directly to the end parse_match: \ - lbu s1, 1(a0) ; \ # (delay slot) Load high byte of offset. - lbu s2, (a0) ; \ # (delay slot) Load low byte of offset. + addiu a0, a0, 2 ; \ # (delay slot) + lbu s1, -1(a0) ; \ # Load high byte of offset. + lbu s2, -2(a0) ; \ # (delay slot) Load low byte of offset. sll s1, s1, 8 ; \ # (delay slot) Shift high byte into place. or s2, s2, s1 ; \ # Combine the two halves. - addiu a0, a0, 2 ; \ subu s2, a1, s2 ; \ # Find position to copy from. addiu s3, s4, -15 ; \ # If match length != 15, no more match bytes addu s4, s4, s2 ; \ # Find end of match input. -- 2.39.5