mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
ReadHelpers: safer.
This commit is contained in:
parent
b219f5fbae
commit
b57f60393e
@ -222,7 +222,12 @@ void readQuotedString(String & s, ReadBuffer & buf);
|
|||||||
inline void readDateText(Yandex::DayNum_t & date, ReadBuffer & buf)
|
inline void readDateText(Yandex::DayNum_t & date, ReadBuffer & buf)
|
||||||
{
|
{
|
||||||
char s[10];
|
char s[10];
|
||||||
buf.read(s, 10);
|
size_t size = buf.read(s, 10);
|
||||||
|
if (10 != size)
|
||||||
|
{
|
||||||
|
s[size] = 0;
|
||||||
|
throw Exception(std::string("Cannot parse date ") + s, ErrorCodes::CANNOT_PARSE_DATE);
|
||||||
|
}
|
||||||
|
|
||||||
UInt16 year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
|
UInt16 year = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
|
||||||
UInt8 month = (s[5] - '0') * 10 + (s[6] - '0');
|
UInt8 month = (s[5] - '0') * 10 + (s[6] - '0');
|
||||||
|
Loading…
Reference in New Issue
Block a user