Commit fc3abcf
authored
Fix four out-of-bounds reads in the lexer and tag URI validation (#547)
Found by running `tests/fuzz_test` under `libFuzzer` and `AddressSanitizer`.
Each of these reads past the end of the input buffer and reproduces on
develop with an input of at most 35 bytes:
* "!<" - `extract_tag_name()` advances past `m_end_itr` before the scanning
loop's end test can fire.
* "!!a%41" - `uri_encoding::validate()` advances the iterator twice per
percent escape, so an escape at the end of the URI moves it past end.
The character after a valid `%XX` was also never validated.
* "%TAG ! " - `scan_tag_directive()` dereferences `m_cur_itr` after
`skip_white_spaces()` may have consumed the rest of the buffer.
* "\"\\\\\\\"" - the backslash counting loop in
`determine_double_quoted_scalar_range()` never examines the token's first
character, so an odd run of backslashes is read as even and the scalar
parser is handed a token one byte short.
Two results change for inputs that did not crash: "!!a%41^" is now
rejected and "!!%41" is now accepted.
Fixes #5461 parent f51e0b5 commit fc3abcf
4 files changed
Lines changed: 79 additions & 8 deletions
File tree
- include/fkYAML/detail
- encodings
- input
- single_include/fkYAML
- tests/unit_test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
40 | 45 | | |
41 | 46 | | |
42 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
557 | 562 | | |
558 | 563 | | |
559 | 564 | | |
| |||
684 | 689 | | |
685 | 690 | | |
686 | 691 | | |
687 | | - | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
688 | 695 | | |
689 | 696 | | |
690 | 697 | | |
| |||
816 | 823 | | |
817 | 824 | | |
818 | 825 | | |
819 | | - | |
820 | | - | |
| 826 | + | |
| 827 | + | |
821 | 828 | | |
822 | 829 | | |
823 | 830 | | |
824 | | - | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
825 | 838 | | |
826 | 839 | | |
827 | 840 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1310 | 1310 | | |
1311 | 1311 | | |
1312 | 1312 | | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
1313 | 1318 | | |
1314 | 1319 | | |
1315 | 1320 | | |
| |||
3782 | 3787 | | |
3783 | 3788 | | |
3784 | 3789 | | |
| 3790 | + | |
| 3791 | + | |
| 3792 | + | |
| 3793 | + | |
| 3794 | + | |
3785 | 3795 | | |
3786 | 3796 | | |
3787 | 3797 | | |
| |||
3912 | 3922 | | |
3913 | 3923 | | |
3914 | 3924 | | |
3915 | | - | |
| 3925 | + | |
| 3926 | + | |
| 3927 | + | |
3916 | 3928 | | |
3917 | 3929 | | |
3918 | 3930 | | |
| |||
4044 | 4056 | | |
4045 | 4057 | | |
4046 | 4058 | | |
4047 | | - | |
4048 | | - | |
| 4059 | + | |
| 4060 | + | |
4049 | 4061 | | |
4050 | 4062 | | |
4051 | 4063 | | |
4052 | | - | |
| 4064 | + | |
| 4065 | + | |
| 4066 | + | |
| 4067 | + | |
| 4068 | + | |
| 4069 | + | |
| 4070 | + | |
4053 | 4071 | | |
4054 | 4072 | | |
4055 | 4073 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
121 | 156 | | |
0 commit comments