Commit e2b7c99
Fix REPLACE buffer overflow for large output strings
Gandiva's REPLACE hardcoded a 65535-byte output cap, throwing
"Buffer overflow for output string" whenever the result exceeded 64 KB.
Size the output buffer to the exact result instead, by counting
non-overlapping matches of from_str: text_len + num_matches *
(to_str_len - from_str_len). Removes the arbitrary cap; the internal
replace_with_max_len variant and its bounds checks are unchanged.
Gandiva variable-length output uses int32 offsets, so a single output
string cannot exceed INT_MAX (2 GB). Guard that boundary explicitly with
a clear error message instead of letting the int32 size cast wrap
silently (which could otherwise lead to under-allocation).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent a81e6c6 commit e2b7c99
2 files changed
Lines changed: 62 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1914 | 1914 | | |
1915 | 1915 | | |
1916 | 1916 | | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
1917 | 1941 | | |
1918 | | - | |
1919 | | - | |
| 1942 | + | |
| 1943 | + | |
1920 | 1944 | | |
1921 | 1945 | | |
1922 | 1946 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1971 | 1971 | | |
1972 | 1972 | | |
1973 | 1973 | | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
1974 | 2010 | | |
1975 | 2011 | | |
1976 | 2012 | | |
| |||
0 commit comments