Skip to content

Commit

Permalink
Coverity-415952: Remove logically dead code
Browse files Browse the repository at this point in the history
In aspack decrypt function, there's a check to make sure that backbytes
doesn't exceed 57, because it is used as an index in init_array.
However, it is mathematically impossible.
So this commit removes the check.
  • Loading branch information
micahsnyder committed Aug 9, 2023
1 parent 9534790 commit 4c8f3a2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libclamav/aspack.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ static int decrypt(struct ASPK *stream, uint8_t *stuff, uint32_t size, uint8_t *
if (!build_decrypt_dictionaries(stream)) return 0;
continue;
}
if ((backbytes = (gen - 256) >> 3) >= 58) return 0; /* checks init_array + stuff */
backbytes = (gen - 256) >> 3;
// backbytes is < 720. 719 - 256 = 463. 463 >> 3 = 57 (max).
// So backbytes cannot overrun the init_array.

backsize = ((gen - 256) & 7) + 2;
if ((backsize - 2) == 7) {
uint8_t hlp;
Expand Down

0 comments on commit 4c8f3a2

Please sign in to comment.