Commit 466e42c
committed
lite: fix stack overflow in NFA compiler
This commit fixes a bug where the parser could produce a very deeply
nested Hir value beyond the configured nested limit. This was caused by
the fact that the Hir can have some of its nested structures added to it
without a corresponding recursive call in the parser. For example,
repetition operators. This means that even if we don't blow the nest
limit in the parser, the Hir itself can still become nested beyond the
limit. This in turn will make it possible to unintentionally overflow
the stack in subsequent recursion over the Hir value, such as in the
Thompson NFA compiler.
We fix this by checking the nesting limit both on every recursive parse
call and also on the depth of the final Hir value once parsing is
finished but before it has returned to the caller.
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=606081 parent 5dff4bd commit 466e42c
3 files changed
Lines changed: 72 additions & 5 deletions
File tree
- fuzz/regressions
- regex-lite
- src/hir
- tests/fuzz
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
380 | 398 | | |
381 | 399 | | |
382 | 400 | | |
| |||
806 | 824 | | |
807 | 825 | | |
808 | 826 | | |
809 | | - | |
| 827 | + | |
810 | 828 | | |
811 | 829 | | |
812 | 830 | | |
| |||
826 | 844 | | |
827 | 845 | | |
828 | 846 | | |
829 | | - | |
| 847 | + | |
830 | 848 | | |
831 | 849 | | |
832 | 850 | | |
833 | | - | |
| 851 | + | |
834 | 852 | | |
835 | 853 | | |
836 | 854 | | |
| |||
1263 | 1281 | | |
1264 | 1282 | | |
1265 | 1283 | | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
1266 | 1316 | | |
1267 | 1317 | | |
1268 | 1318 | | |
| |||
1344 | 1394 | | |
1345 | 1395 | | |
1346 | 1396 | | |
1347 | | - | |
| 1397 | + | |
1348 | 1398 | | |
1349 | 1399 | | |
1350 | 1400 | | |
1351 | 1401 | | |
1352 | | - | |
| 1402 | + | |
1353 | 1403 | | |
1354 | 1404 | | |
1355 | 1405 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
17 | 34 | | |
18 | 35 | | |
19 | 36 | | |
| |||
0 commit comments