Commit a82a5c9
committed
Fix BzDecoder to propagate UnexpectedEof error on truncated streams
Fixes #411
The async BzDecoder was silently accepting truncated bzip2 streams,
returning Ok(0) instead of raising an error. This contrasts with the
synchronous bzip2::read::BzDecoder which properly returns an
UnexpectedEof error.
Added state tracking to BzDecoder:
- Added stream_ended field to track if Status::StreamEnd was received
- Modified decode() to set stream_ended = true on Status::StreamEnd
- Updated finish() to check stream_ended and return UnexpectedEof if false
This ensures applications cannot accidentally accept corrupted or
incomplete compressed data as valid, matching the behavior of the
synchronous decoder.
The generic truncated test now passes for bzip2.1 parent 71d1d68 commit a82a5c9
1 file changed
+16
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
52 | 59 | | |
53 | 60 | | |
54 | 61 | | |
55 | 62 | | |
56 | 63 | | |
57 | 64 | | |
58 | 65 | | |
| 66 | + | |
59 | 67 | | |
60 | 68 | | |
61 | 69 | | |
| |||
101 | 109 | | |
102 | 110 | | |
103 | 111 | | |
104 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
105 | 120 | | |
106 | 121 | | |
0 commit comments