Skip to content

Commit a625923

Browse files
authored
Fix out-of-bounds access in DEFLATE stored block decompression (#2)
1 parent d56d0b9 commit a625923

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/inflate.mbt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ fn inflt(
7171
if btype == 0 {
7272
// stored block
7373
let s = shft(pos) + 4
74+
// Check if we have enough bytes for the stored block header (4 bytes)
75+
if s > dat_end {
76+
if no_st != 0 {
77+
raise fzip_err(UnexpectedEOF)
78+
}
79+
break
80+
}
7481
let l = dat[s - 4].to_int() | (dat[s - 3].to_int() << 8)
7582
let t = s + l
7683
if t > dat_end {

0 commit comments

Comments
 (0)