aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprimorial <primorial@yandex-team.com>2022-09-29 12:59:22 +0300
committerprimorial <primorial@yandex-team.com>2022-09-29 12:59:22 +0300
commit9caf30122c4c97609311cbe989af1c6c2ac3bcf0 (patch)
tree4d65080a2f6c41c998bf0acd183a49d742dda7fb
parentf0dccf23552f6620c69d0533c0ef596dbcb2e18e (diff)
downloadydb-9caf30122c4c97609311cbe989af1c6c2ac3bcf0.tar.gz
CONTRIB: fix apache orc UB from ubsan at column reader with patch
-rw-r--r--contrib/libs/apache/orc/c++/src/ColumnReader.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/contrib/libs/apache/orc/c++/src/ColumnReader.cc b/contrib/libs/apache/orc/c++/src/ColumnReader.cc
index f4a4df9248..873b54c618 100644
--- a/contrib/libs/apache/orc/c++/src/ColumnReader.cc
+++ b/contrib/libs/apache/orc/c++/src/ColumnReader.cc
@@ -449,7 +449,7 @@ namespace orc {
int64_t bits = 0;
if (bufferEnd - bufferPointer >= 8) {
if (isLittleEndian) {
- bits = *(reinterpret_cast<const int64_t*>(bufferPointer));
+ memcpy(&bits, bufferPointer, sizeof(bits));
} else {
bits = static_cast<int64_t>(static_cast<unsigned char>(bufferPointer[0]));
bits |= static_cast<int64_t>(static_cast<unsigned char>(bufferPointer[1])) << 8;
@@ -564,8 +564,12 @@ namespace orc {
bufferNum = std::min(numValues,
static_cast<size_t>(bufferEnd - bufferPointer) / bytesPerValue);
uint64_t bufferBytes = bufferNum * bytesPerValue;
- memcpy(outArray, bufferPointer, bufferBytes);
- bufferPointer += bufferBytes;
+ if (bufferPointer && bufferBytes) {
+ memcpy(outArray, bufferPointer, bufferBytes);
+ bufferPointer += bufferBytes;
+ } else {
+ bufferNum = 0;
+ }
}
for (size_t i = bufferNum; i < numValues; ++i) {
outArray[i] = readDouble();