-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40284 from ClickHouse/backport/22.7/40241
Backport #40241 to 22.7: Fix possible segfault in CapnProto input format
- Loading branch information
Showing
5 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
tests/queries/0_stateless/02402_capnp_format_segments_overflow.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
OK |
23 changes: 23 additions & 0 deletions
23
tests/queries/0_stateless/02402_capnp_format_segments_overflow.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
# Tags: no-fasttest, no-parallel, no-replicated-database | ||
|
||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) | ||
# shellcheck source=../shell_config.sh | ||
. "$CURDIR"/../shell_config.sh | ||
|
||
USER_FILES_PATH=$(clickhouse-client --query "select _path,_file from file('nonexist.txt', 'CSV', 'val1 char')" 2>&1 | grep Exception | awk '{gsub("/nonexist.txt","",$9); print $9}') | ||
mkdir -p $USER_FILES_PATH/test_02402 | ||
cp $CURDIR/data_capnp/overflow.capnp $USER_FILES_PATH/test_02402/ | ||
|
||
SCHEMADIR=$(clickhouse-client --query "select * from file('test_02402/overflow.capnp', 'CapnProto', 'val1 char') settings format_schema='nonexist:Message'" 2>&1 | grep Exception | grep -oP "file \K.*(?=/nonexist.capnp)") | ||
|
||
CLIENT_SCHEMADIR=$CURDIR/format_schemas | ||
SERVER_SCHEMADIR=test_02402 | ||
|
||
mkdir -p $SCHEMADIR/$SERVER_SCHEMADIR | ||
cp -r $CLIENT_SCHEMADIR/02402_* $SCHEMADIR/$SERVER_SCHEMADIR/ | ||
|
||
$CLICKHOUSE_CLIENT --query="SELECT * FROM file('test_02402/overflow.capnp', 'CapnProto') SETTINGS format_schema='$SERVER_SCHEMADIR/02402_overflow:CapnProto'" 2>&1 | grep -F -q "INCORRECT_DATA" && echo 'OK' || echo 'FAIL'; | ||
|
||
rm -rf $USER_FILES_PATH/test_02402 | ||
rm -rf ${SCHEMADIR:?}/${SERVER_SCHEMADIR:?} |
Binary file not shown.
30 changes: 30 additions & 0 deletions
30
tests/queries/0_stateless/format_schemas/02402_overflow.capnp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@0x803231eaa402b968; | ||
|
||
struct NestedNestedOne | ||
{ | ||
nestednestednumber @0 : UInt64; | ||
} | ||
struct NestedNestedTwo | ||
{ | ||
nestednestedtext @0 : Text; | ||
} | ||
struct NestedOne | ||
{ | ||
nestednestedone @0 : NestedNestedOne; | ||
nestednestedtwo @1 : NestedNestedTwo; | ||
nestednumber @2: UInt64; | ||
} | ||
struct NestedTwo | ||
{ | ||
nestednestedone @0 : NestedNestedOne; | ||
nestednestedtwo @1 : NestedNestedTwo; | ||
nestedtext @2 : Text; | ||
} | ||
struct CapnProto | ||
{ | ||
number @0 : UInt64; | ||
string @1 : Text; | ||
nestedone @2 : NestedOne; | ||
nestedtwo @3 : NestedTwo; | ||
nestedthree @4 : NestedNestedTwo; | ||
} |