mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Check row size to avoid out of bounds access
This commit is contained in:
parent
f72e509b3b
commit
54e599161d
@ -1,4 +1,5 @@
|
||||
#include "PostgreSQLSource.h"
|
||||
#include "Common/Exception.h"
|
||||
|
||||
#if USE_LIBPQXX
|
||||
#include <Columns/ColumnNullable.h>
|
||||
@ -22,6 +23,10 @@
|
||||
namespace DB
|
||||
{
|
||||
|
||||
namespace ErrorCodes
|
||||
{
|
||||
extern const int TOO_MANY_COLUMNS;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
PostgreSQLSource<T>::PostgreSQLSource(
|
||||
@ -123,6 +128,11 @@ Chunk PostgreSQLSource<T>::generate()
|
||||
if (!row)
|
||||
break;
|
||||
|
||||
if (row->size() > description.sample_block.columns())
|
||||
throw Exception(ErrorCodes::TOO_MANY_COLUMNS,
|
||||
"Row has too many columns: {}, expected structure: {}",
|
||||
row->size(), description.sample_block.dumpStructure());
|
||||
|
||||
for (const auto idx : collections::range(0, row->size()))
|
||||
{
|
||||
const auto & sample = description.sample_block.getByPosition(idx);
|
||||
|
Loading…
Reference in New Issue
Block a user