You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-07-17 15:00:59 +03:00
fix(ubsan): MCOL-5844 - iron out UBSAN reports
The most important fix here is the fix of possible buffer overrun in DATEFORMAT() function. A "%W" format, repeated enough times, would overflow the 256-bytes buffer for result. Now we use ostringstream to construct result and we are safe. Changes in date/time projection functions made me fix difference between us and server behavior. The new, better behavior is reflected in changes in tests' results. Also, there was incorrect logic in TRUNCATE() and ROUND() functions in computing the decimal "shift."
This commit is contained in:
committed by
Sergey Zefirov
parent
63abfd92fd
commit
0bc384d5f0
@ -127,6 +127,30 @@ void Message::Args::add(uint64_t u64)
|
||||
fArgs.push_back(u64);
|
||||
}
|
||||
|
||||
void Message::Args::add(int128_t i128)
|
||||
{
|
||||
uint128_t x = i128 < 0 ? -i128 : i128;
|
||||
std::vector<char> digits;
|
||||
std::ostringstream oss;
|
||||
while (x > 0) {
|
||||
char c = (x % 10) + '0';
|
||||
digits.push_back(c);
|
||||
x /= 10;
|
||||
}
|
||||
if (digits.size() < 1) {
|
||||
digits.push_back('0');
|
||||
}
|
||||
if (i128 < 0)
|
||||
{
|
||||
oss << '-';
|
||||
}
|
||||
for(int32_t i=int(digits.size() - 1); i >= 0; i--)
|
||||
{
|
||||
oss << digits[i];
|
||||
}
|
||||
fArgs.push_back(oss.str());
|
||||
}
|
||||
|
||||
void Message::Args::add(const string& s)
|
||||
{
|
||||
fArgs.push_back(s);
|
||||
|
Reference in New Issue
Block a user