# zstd: Protect against index out-of-bounds when decoding sequences · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/98547713a354efef406ca79731db8984eb26c051)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 98547713a354efef406ca79731db8984eb26c051

Requested commit: 98547713a354efef406ca79731db8984eb26c051

Commit: 98547713a354efef406ca79731db8984eb26c051

Tree: d0af6057b62cfc741d8d9313ac7e67e2abcde1d8

Author: Ryan Liptak

Committer: Andrew Kelley

## Message

```
zstd: Protect against index out-of-bounds when decoding sequences

Previously, index out-of-bounds could occur when copying match_length bytes while decoding whatever sequence happened to overflow `dest`. Now, each sequence checks that there is enough room for the full sequence_length (literal_length + match_length) before doing any copying.

Fixes the failing inputs found here: https://github.com/ziglang/zig/issues/24817#issuecomment-3192927715

```

## Parents

- [ee85c8b6d05dbda541d4b0b8b402aafad8e582a3](https://git.cafe/gitcafe/zig/commit/ee85c8b6d05dbda541d4b0b8b402aafad8e582a3?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/98547713a354efef406ca79731db8984eb26c051?format=markdown)
