- Notifications
You must be signed in to change notification settings - Fork5
Commit2a4c46e
committed
Fix array overrun in regex code.
zaptreesubs() was coded to unconditionally reset a capture subre'scorresponding pmatch[] entry. However, in regexes without backrefs, thatarray is caller-supplied and might not have as many entries as the regexhas capturing parens. So check the array length and do nothing if thereis no corresponding entry, much as subset() does. Failure to check thisresulted in a stack clobber in the case reported by Marko Kreen.This bug appears to have been latent in the regex library from thebeginning. It was not exposed because find() called dissect() notcdissect(), and the dissect() code path didn't ever call zaptreesubs()(formerly zapmem()). When I unified dissect() and cdissect() in commit4dd78bf, the problem was exposed.Now that I've seen this, I'm rather suspicious that we might need toback-patch it; but will refrain for now, for lack of evidence thatthe case can be hit in the previous coding.1 parentace397e commit2a4c46e
3 files changed
+33
-4
lines changedLines changed: 9 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
531 | 531 |
| |
532 | 532 |
| |
533 | 533 |
| |
534 |
| - | |
535 |
| - | |
536 |
| - | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
537 | 542 |
| |
538 | 543 |
| |
539 | 544 |
| |
| |||
543 | 548 |
| |
544 | 549 |
| |
545 | 550 |
| |
546 |
| - | |
| 551 | + | |
547 | 552 |
| |
548 | 553 |
| |
549 | 554 |
| |
|
Lines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
71 | 71 |
| |
72 | 72 |
| |
73 | 73 |
| |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + |
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
19 | 19 |
| |
20 | 20 |
| |
21 | 21 |
| |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + |
0 commit comments
Comments
(0)