Commit f8bd020
committed
Fix out-of-bounds access in read_quoted_text()
The backslash-counting loop in read_quoted_text() ran before the EOF
check. When strcspn() reached the end of the string without finding a
closing quote, the loop accessed offsets past the string boundary:
1. strcspn() sets $at = strlen($sql) (no quote found).
2. Backslash check finds '\' at $at-1 (last byte), counts it ($i=1).
3. Odd count → treats absent quote as escaped, does $at += 1 (past end).
4. Next iteration: strcspn returns 0, $at stays past end.
5. Backslash check accesses $this->sql[strlen($sql)] → PHP warning.
Fix: move the EOF check before the backslash-counting loop so unclosed
strings are detected immediately. Also add a lower-bound guard to the
backward walk to prevent underflow when a quote appears early in the
string.1 parent 040d5a6 commit f8bd020
1 file changed
Lines changed: 6 additions & 6 deletions
Lines changed: 6 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2842 | 2842 | | |
2843 | 2843 | | |
2844 | 2844 | | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
2845 | 2850 | | |
2846 | 2851 | | |
2847 | 2852 | | |
| |||
2852 | 2857 | | |
2853 | 2858 | | |
2854 | 2859 | | |
2855 | | - | |
| 2860 | + | |
2856 | 2861 | | |
2857 | 2862 | | |
2858 | 2863 | | |
2859 | 2864 | | |
2860 | 2865 | | |
2861 | 2866 | | |
2862 | | - | |
2863 | | - | |
2864 | | - | |
2865 | | - | |
2866 | | - | |
2867 | 2867 | | |
2868 | 2868 | | |
2869 | 2869 | | |
| |||
0 commit comments