Commit 8408a5d
authored
fix(expressions): bound the DNF expansion in rewrite_to_dnf (#3995)
Converting to DNF distributes every AND over the ORs below it, so a filter
with n two-branch OR groups expands to 2**n terms. Nothing bounded that, so a
small user-supplied filter could produce an expression no consumer can use:
20 groups reached 1,048,576 terms in ~17s and ~1 GiB.
Cap the expansion at MAX_DNF_TERMS and raise before the product is built, so
the same input now fails in 0.22s.1 parent 7e7d340 commit 8408a5d
2 files changed
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
974 | 974 | | |
975 | 975 | | |
976 | 976 | | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
977 | 983 | | |
978 | 984 | | |
979 | 985 | | |
| |||
991 | 997 | | |
992 | 998 | | |
993 | 999 | | |
| 1000 | + | |
| 1001 | + | |
994 | 1002 | | |
995 | 1003 | | |
996 | 1004 | | |
| |||
1008 | 1016 | | |
1009 | 1017 | | |
1010 | 1018 | | |
| 1019 | + | |
1011 | 1020 | | |
1012 | 1021 | | |
1013 | 1022 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
1594 | 1595 | | |
1595 | 1596 | | |
1596 | 1597 | | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
1597 | 1615 | | |
1598 | 1616 | | |
1599 | 1617 | | |
| |||
0 commit comments