forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd5622ac
committed
Replace usages of xmlXPathCompile() with xmlXPathCtxtCompile().
In existing releases of libxml2, xmlXPathCompile can be drivento stack overflow because it fails to protect itself againsttoo-deeply-nested input. While there is an upstream fix as ofyesterday, it will take years for that to propagate into allshipping versions. In the meantime, we can protect our ownusages basically for free by calling xmlXPathCtxtCompile instead.(The actual bug is that libxml2 keeps its nesting counter in thexmlXPathContext, and its parsing code was willing to just skipcounting nesting levels if it didn't have a context. So if we supplya context, all is well. It seems odd actually that it works at allto not supply a context, because this means that XPath parsing doesnot have access to XML namespace info. Apparently libxml2 neverchecks namespaces until runtime? Anyway, this seems like goodfuture-proofing even if its only immediate effect is to dodge a bug.)Sadly, this hack only offers protection with libxml2 2.9.11 and newer.Before that there are multiple similar problems, so if you areprocessing untrusted XML it behooves you to get a newer version.But we have some pretty old libxml2 in the buildfarm, so it seemsimpractical to add a regression test to verify this fix.Per bug #18617 from Jingzhou Fu. Back-patch to all supportedversions.Discussion:https://postgr.es/m/18617-1cee4d2ed1f4e7ae@postgresql.orgDiscussion:https://gitlab.gnome.org/GNOME/libxml2/-/issues/7991 parent43ce181 commitd5622ac
2 files changed
+17
-5
lines changedLines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
386 | 386 |
| |
387 | 387 |
| |
388 | 388 |
| |
389 |
| - | |
| 389 | + | |
390 | 390 |
| |
391 | 391 |
| |
392 | 392 |
| |
| |||
649 | 649 |
| |
650 | 650 |
| |
651 | 651 |
| |
652 |
| - | |
| 652 | + | |
653 | 653 |
| |
654 | 654 |
| |
655 | 655 |
| |
|
Lines changed: 15 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4448 | 4448 |
| |
4449 | 4449 |
| |
4450 | 4450 |
| |
4451 |
| - | |
| 4451 | + | |
| 4452 | + | |
| 4453 | + | |
| 4454 | + | |
| 4455 | + | |
| 4456 | + | |
| 4457 | + | |
4452 | 4458 |
| |
4453 | 4459 |
| |
4454 | 4460 |
| |
| |||
4819 | 4825 |
| |
4820 | 4826 |
| |
4821 | 4827 |
| |
4822 |
| - | |
| 4828 | + | |
| 4829 | + | |
| 4830 | + | |
| 4831 | + | |
4823 | 4832 |
| |
4824 | 4833 |
| |
4825 | 4834 |
| |
| |||
4850 | 4859 |
| |
4851 | 4860 |
| |
4852 | 4861 |
| |
4853 |
| - | |
| 4862 | + | |
| 4863 | + | |
| 4864 | + | |
| 4865 | + | |
4854 | 4866 |
| |
4855 | 4867 |
| |
4856 | 4868 |
| |
|
0 commit comments
Comments
(0)