Repository navigation
Commit 291252d
committed
Fix bzopen() ownership of the stream it wraps
bzopen() with a stream argument, and the wrapper fallback in
_php_stream_bz2open(), pass the stream's own descriptor to
BZ2_bzdopen(). bzlib takes ownership of it and closes it in
BZ2_bzclose(), after which the inner stream close closes the same
descriptor number again. The bz2 stream also keeps a raw pointer to the
inner stream while holding a reference on its resource only, so closing
the inner stream with fclose() left a dangling pointer that the bz2
close dereferenced, while bzlib kept using a descriptor number that
could already belong to another file.
Hand bzlib a duplicate of the descriptor and resolve the inner stream
from its resource on close, so a closed inner stream is skipped.
Closes GH-238241 parent bba11e6 commit 291252d
3 files changed
Lines changed: 79 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
9 | 13 | | |
10 | 14 | | |
11 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
136 | 143 | | |
137 | 144 | | |
138 | 145 | | |
| |||
158 | 165 | | |
159 | 166 | | |
160 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
161 | 185 | | |
162 | 186 | | |
163 | 187 | | |
164 | 188 | | |
165 | 189 | | |
166 | 190 | | |
167 | 191 | | |
168 | | - | |
| 192 | + | |
169 | 193 | | |
| 194 | + | |
170 | 195 | | |
171 | 196 | | |
172 | 197 | | |
| |||
223 | 248 | | |
224 | 249 | | |
225 | 250 | | |
226 | | - | |
| 251 | + | |
227 | 252 | | |
228 | 253 | | |
229 | 254 | | |
| |||
399 | 424 | | |
400 | 425 | | |
401 | 426 | | |
402 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
403 | 431 | | |
404 | 432 | | |
405 | 433 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
0 commit comments