Repository navigation
Commit ae506de
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.1 parent 39f98f7 commit ae506de
2 files changed
Lines changed: 76 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
| 60 | + | |
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
134 | 141 | | |
135 | 142 | | |
136 | 143 | | |
| |||
156 | 163 | | |
157 | 164 | | |
158 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
159 | 183 | | |
160 | 184 | | |
161 | 185 | | |
162 | 186 | | |
163 | 187 | | |
164 | 188 | | |
165 | 189 | | |
166 | | - | |
| 190 | + | |
167 | 191 | | |
| 192 | + | |
168 | 193 | | |
169 | 194 | | |
170 | 195 | | |
| |||
221 | 246 | | |
222 | 247 | | |
223 | 248 | | |
224 | | - | |
| 249 | + | |
225 | 250 | | |
226 | 251 | | |
227 | 252 | | |
| |||
407 | 432 | | |
408 | 433 | | |
409 | 434 | | |
410 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
411 | 439 | | |
412 | 440 | | |
413 | 441 | | |
| |||
| 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 | + | |
| 42 | + | |
0 commit comments