Skip to content

Commit

Permalink
inflate: Fix handling of zero-length uncompressed block
Browse files Browse the repository at this point in the history
This is a silly case presumably caused by a buggy or unoptimised
compressor, but it has been seen in practice and it is not
explicitly disallowed by RFC 1951.
  • Loading branch information
keirf committed Feb 10, 2025
1 parent ae428d4 commit 6c79397
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions inflate/inflate.S
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,9 @@ uncompressed_block:
moveq #16,d1
jbsr stream_next_bits /* LEN */
addq.w #2,a5 /* skip NLEN */
subq.w #1,d0 /* d0.w = len-1 (for dbf) */
jra 2f /* decrement LEN for DBF loop */
1: move.b (a5)+,(a4)+
dbf d0,1b
2: dbf d0,1b
rts

#define o_hdist /*0*/
Expand Down
4 changes: 2 additions & 2 deletions inflate/inflate.asm
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@ uncompressed_block:
moveq #16,d1
bsr stream_next_bits ; LEN
addq.w #2,a5 ; skip NLEN
subq.w #1,d0 ; d0.w = len-1 (for dbf)
bra .2 ; decrement LEN for DBF loop
.1: move.b (a5)+,(a4)+
dbf d0,.1
.2: dbf d0,.1
rts

o_hdist = 0
Expand Down

0 comments on commit 6c79397

Please sign in to comment.