mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
Merge pull request #5902 from yandex/fix-visit-param-extract-raw
Fixed buffer underflow in visitParamExtractRaw
This commit is contained in:
commit
758de14138
@ -100,7 +100,7 @@ struct ExtractRaw
|
||||
|
||||
for (auto extract_begin = pos; pos != end; ++pos)
|
||||
{
|
||||
if (*pos == current_expect_end)
|
||||
if (current_expect_end && *pos == current_expect_end)
|
||||
{
|
||||
expects_end.pop_back();
|
||||
current_expect_end = expects_end.empty() ? 0 : expects_end.back();
|
||||
@ -192,7 +192,7 @@ struct ExtractParamImpl
|
||||
|
||||
/// We check that the entry does not pass through the boundaries of strings.
|
||||
if (pos + needle.size() < begin + offsets[i])
|
||||
res[i] = ParamExtractor::extract(pos + needle.size(), begin + offsets[i]);
|
||||
res[i] = ParamExtractor::extract(pos + needle.size(), begin + offsets[i] - 1); /// don't include terminating zero
|
||||
else
|
||||
res[i] = 0;
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
|
@ -0,0 +1 @@
|
||||
SELECT visitParamExtractRaw('\"a\":', 'a');
|
@ -0,0 +1,4 @@
|
||||
123
|
||||
Hello
|
||||
Hello
|
||||
0
|
@ -0,0 +1,5 @@
|
||||
SELECT visitParamExtractUInt('"a":123', 'a');
|
||||
SELECT visitParamExtractString('"a":"Hello"', 'a');
|
||||
SELECT visitParamExtractRaw('"a":Hello}', 'a');
|
||||
|
||||
SELECT sum(ignore(visitParamExtractRaw(concat('{"a":', reinterpretAsString(rand64())), 'a'))) FROM numbers(1000000);
|
Loading…
Reference in New Issue
Block a user