mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
Added verification of the length of the protobuff message
This commit is contained in:
parent
ff8ae637ca
commit
514851f0f8
@ -67,7 +67,9 @@ bool ProtobufReader::SimpleReader::startMessage()
|
|||||||
if (unlikely(in.eof()))
|
if (unlikely(in.eof()))
|
||||||
return false;
|
return false;
|
||||||
size_t size_of_message = readVarint();
|
size_t size_of_message = readVarint();
|
||||||
current_message_end = cursor + size_of_message;
|
if(size_of_message == 0)
|
||||||
|
unknownFormat();
|
||||||
|
current_message_end = root_message_end = cursor + size_of_message;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -375,6 +377,10 @@ void ProtobufReader::SimpleReader::ignoreGroup()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[noreturn]] void ProtobufReader::SimpleReader::throwUnknownFormat() const
|
||||||
|
{
|
||||||
|
unknownFormat();
|
||||||
|
}
|
||||||
|
|
||||||
// Implementation for a converter from any protobuf field type to any DB data type.
|
// Implementation for a converter from any protobuf field type to any DB data type.
|
||||||
class ProtobufReader::ConverterBaseImpl : public ProtobufReader::IConverter
|
class ProtobufReader::ConverterBaseImpl : public ProtobufReader::IConverter
|
||||||
|
@ -97,7 +97,15 @@ private:
|
|||||||
bool readUInt(UInt64 & value);
|
bool readUInt(UInt64 & value);
|
||||||
template<typename T> bool readFixed(T & value);
|
template<typename T> bool readFixed(T & value);
|
||||||
bool readStringInto(PaddedPODArray<UInt8> & str);
|
bool readStringInto(PaddedPODArray<UInt8> & str);
|
||||||
bool ALWAYS_INLINE maybeCanReadValue() const { return field_end != REACHED_END; }
|
bool ALWAYS_INLINE maybeCanReadValue() const
|
||||||
|
{
|
||||||
|
if (field_end == REACHED_END)
|
||||||
|
return false;
|
||||||
|
if (cursor < root_message_end)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
throwUnknownFormat();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void readBinary(void* data, size_t size);
|
void readBinary(void* data, size_t size);
|
||||||
@ -119,6 +127,8 @@ private:
|
|||||||
void ignoreVarint();
|
void ignoreVarint();
|
||||||
void ignoreGroup();
|
void ignoreGroup();
|
||||||
|
|
||||||
|
[[noreturn]] void throwUnknownFormat() const;
|
||||||
|
|
||||||
static constexpr UInt64 REACHED_END = 0;
|
static constexpr UInt64 REACHED_END = 0;
|
||||||
|
|
||||||
ReadBuffer & in;
|
ReadBuffer & in;
|
||||||
@ -126,6 +136,8 @@ private:
|
|||||||
std::vector<UInt64> parent_message_ends;
|
std::vector<UInt64> parent_message_ends;
|
||||||
UInt64 current_message_end;
|
UInt64 current_message_end;
|
||||||
UInt64 field_end;
|
UInt64 field_end;
|
||||||
|
|
||||||
|
UInt64 root_message_end;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IConverter
|
class IConverter
|
||||||
|
Loading…
Reference in New Issue
Block a user