From bce646950ae5679d2fcf4d59c994f21e28dc4234 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20Dub=C3=A9?= <159546+serprex@users.noreply.github.com> Date: Thu, 28 May 2026 06:35:43 +0000 Subject: [PATCH] client.cpp: remove support for nested exceptions these are a vulnerability vector (stack overflow) support removed in ClickHouse itself: https://github.com/ClickHouse/ClickHouse/commit/67afaa9d93aa299b806a112044d3923faefed7ef --- clickhouse/client.cpp | 42 +++++++---------------------------- clickhouse/server_exception.h | 3 --- 2 files changed, 8 insertions(+), 37 deletions(-) diff --git a/clickhouse/client.cpp b/clickhouse/client.cpp index b41e0ba3..74e74dc3 100644 --- a/clickhouse/client.cpp +++ b/clickhouse/client.cpp @@ -753,40 +753,14 @@ bool Client::Impl::ReceiveData() { bool Client::Impl::ReceiveException(bool rethrow) { std::shared_ptr e(new Exception); - Exception* current = e.get(); - - bool exception_received = true; - do { - bool has_nested = false; - - if (!WireFormat::ReadFixed(*input_, ¤t->code)) { - exception_received = false; - break; - } - if (!WireFormat::ReadString(*input_, ¤t->name)) { - exception_received = false; - break; - } - if (!WireFormat::ReadString(*input_, ¤t->display_text)) { - exception_received = false; - break; - } - if (!WireFormat::ReadString(*input_, ¤t->stack_trace)) { - exception_received = false; - break; - } - if (!WireFormat::ReadFixed(*input_, &has_nested)) { - exception_received = false; - break; - } - - if (has_nested) { - current->nested.reset(new Exception); - current = current->nested.get(); - } else { - break; - } - } while (true); + bool has_nested = false; // obsolete: https://github.com/ClickHouse/ClickHouse/blob/ef11941cf5a/src/IO/ReadHelpers.cpp#L2017 + + bool exception_received = + WireFormat::ReadFixed(*input_, &e->code) + && WireFormat::ReadString(*input_, &e->name) + && WireFormat::ReadString(*input_, &e->display_text) + && WireFormat::ReadString(*input_, &e->stack_trace) + && WireFormat::ReadFixed(*input_, &has_nested); if (events_) { events_->OnServerException(*e); diff --git a/clickhouse/server_exception.h b/clickhouse/server_exception.h index dcc97c51..89aff052 100644 --- a/clickhouse/server_exception.h +++ b/clickhouse/server_exception.h @@ -1,7 +1,6 @@ #pragma once #include -#include namespace clickhouse { struct Exception { @@ -9,8 +8,6 @@ struct Exception { std::string name; std::string display_text; std::string stack_trace; - /// Pointer to nested exception. - std::unique_ptr nested; }; }