Commit e735d2b
committed
Fix phpGH-17808: PharFileInfo refcount bug
PharFileInfo just takes a pointer from the manifest without refcounting
anything. If the entry is then removed from the manifest while the
PharFileInfo object still exists, we get a UAF.
We fix this by using the fp_refcount field. This is technically a
behaviour change as the unlinking is now blocked, and potentially file
modifications can be blocked as well. The alternative would be to have a
field that indicates whether deletion is blocked, but similar corruption
bugs may occur as well with file overwrites, so we increment fp_refcount
instead.
This also fixes an issue where a destructor called multiple times
resulted in a UAF as well, by moving the NULL'ing of the entry field out
of the if.
Closes phpGH-17811.1 parent 0f63bee commit e735d2b
3 files changed
+37
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4483 | 4483 | | |
4484 | 4484 | | |
4485 | 4485 | | |
| 4486 | + | |
| 4487 | + | |
| 4488 | + | |
4486 | 4489 | | |
4487 | 4490 | | |
4488 | 4491 | | |
| |||
4512 | 4515 | | |
4513 | 4516 | | |
4514 | 4517 | | |
4515 | | - | |
| 4518 | + | |
| 4519 | + | |
| 4520 | + | |
| 4521 | + | |
| 4522 | + | |
4516 | 4523 | | |
4517 | 4524 | | |
4518 | 4525 | | |
4519 | 4526 | | |
4520 | 4527 | | |
4521 | 4528 | | |
4522 | | - | |
| 4529 | + | |
| 4530 | + | |
| 4531 | + | |
4523 | 4532 | | |
| 4533 | + | |
| 4534 | + | |
4524 | 4535 | | |
4525 | 4536 | | |
4526 | 4537 | | |
| |||
| 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 | + | |
0 commit comments