diff options
author | Jason Carey <jcarey@argv.me> | 2018-10-22 16:24:53 -0400 |
---|---|---|
committer | Jason Carey <jcarey@argv.me> | 2018-10-23 11:36:02 -0400 |
commit | bb91ac5a2c0b647b80d65d4aaf5a448351b9cc33 (patch) | |
tree | fb8b12deb3bc131648e0990cb8b524c0439b3869 /src/mongo/base/data_range_cursor_test.cpp | |
parent | 1d05a7b3852c6898cab4aae738c9920861f073bd (diff) | |
download | mongo-bb91ac5a2c0b647b80d65d4aaf5a448351b9cc33.tar.gz |
SERVER-37258 Fix UB in MurmurHash3
When we did the data view integration into murmurhash3 (to make it big
endian safe) we missed that murmurhash3 uses negative offsets of
pointers. Because DataView took size_t for offsetting parameters, this
involved wrapping pointers around (adding very large numbers to pointers
to produce negative offsets). That's UB, and newer ubsan caught it.
This change fixes that by making the DataView offsetting logic ptrdiff_t
based.
It also introduces test vectors for murmurhash3 that I've used to verify
that we haven't changed its output.
Diffstat (limited to 'src/mongo/base/data_range_cursor_test.cpp')
-rw-r--r-- | src/mongo/base/data_range_cursor_test.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/mongo/base/data_range_cursor_test.cpp b/src/mongo/base/data_range_cursor_test.cpp index d4170aaae44..41cb4c820f2 100644 --- a/src/mongo/base/data_range_cursor_test.cpp +++ b/src/mongo/base/data_range_cursor_test.cpp @@ -67,7 +67,7 @@ TEST(DataRangeCursor, ConstDataRangeCursorType) { ConstDataRangeCursor out(nullptr, nullptr); - auto inner = cdrc.read(&out); + auto inner = cdrc.readInto(&out); ASSERT_OK(inner); ASSERT_EQUALS(buf, out.data()); @@ -100,7 +100,7 @@ TEST(DataRangeCursor, DataRangeCursorType) { DataRangeCursor out(nullptr, nullptr); - Status status = drc.read(&out); + Status status = drc.readInto(&out); ASSERT_OK(status); ASSERT_EQUALS(buf, out.data()); |