summaryrefslogtreecommitdiff
path: root/src/mongo/util/bufreader.h
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2018-10-22 16:24:53 -0400
committerJason Carey <jcarey@argv.me>2018-10-23 11:36:02 -0400
commitbb91ac5a2c0b647b80d65d4aaf5a448351b9cc33 (patch)
treefb8b12deb3bc131648e0990cb8b524c0439b3869 /src/mongo/util/bufreader.h
parent1d05a7b3852c6898cab4aae738c9920861f073bd (diff)
downloadmongo-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/util/bufreader.h')
-rw-r--r--src/mongo/util/bufreader.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mongo/util/bufreader.h b/src/mongo/util/bufreader.h
index 74a8b5a319c..c43f3253aeb 100644
--- a/src/mongo/util/bufreader.h
+++ b/src/mongo/util/bufreader.h
@@ -78,7 +78,7 @@ public:
/** read in the object specified, but do not advance buffer pointer */
template <typename T>
void peek(T& t) const {
- uassertStatusOK(ConstDataRange(_pos, _end).read(&t));
+ uassertStatusOK(ConstDataRange(_pos, _end).readInto(&t));
}
/** read in and return an object of the specified type, but do not advance buffer pointer */