diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-06-28 11:57:36 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-06-28 12:07:38 -0400 |
commit | f55598f870b2346ed48a32befc51b9a548b8b5fa (patch) | |
tree | 5fa1304359f9f66f97bb93fd9772acfaf9f6759e /src/ext | |
parent | c34a6b922f3e5ff22c99c70bfe3832b647ce5b49 (diff) | |
download | tor-f55598f870b2346ed48a32befc51b9a548b8b5fa.tar.gz tor-f55598f870b2346ed48a32befc51b9a548b8b5fa.zip |
Coverity: different implementation for csiphash
Coverity has had trouble figuring out our csiphash implementation,
and has given spurious warnings about its behavior.
This patch changes the csiphash implementation when coverity is in
use, so that coverity can figure out that we are not about to read
beyond the provided input.
Closes ticket 31025.
Diffstat (limited to 'src/ext')
-rw-r--r-- | src/ext/csiphash.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ext/csiphash.c b/src/ext/csiphash.c index af8559a476..faa52ae4e1 100644 --- a/src/ext/csiphash.c +++ b/src/ext/csiphash.c @@ -87,6 +87,13 @@ uint64_t siphash24(const void *src, unsigned long src_sz, const struct sipkey *k v0 ^= mi; } +#ifdef __COVERITY__ + { + uint64_t mi = 0; + memcpy(&mi, m+i, (src_sz-blocks)); + last7 = _le64toh(mi) | (uint64_t)(src_sz & 0xff) << 56; + } +#else switch (src_sz - blocks) { case 7: last7 |= (uint64_t)m[i + 6] << 48; /* Falls through. */ case 6: last7 |= (uint64_t)m[i + 5] << 40; /* Falls through. */ @@ -98,6 +105,7 @@ uint64_t siphash24(const void *src, unsigned long src_sz, const struct sipkey *k case 0: default:; } +#endif v3 ^= last7; DOUBLE_ROUND(v0,v1,v2,v3); v0 ^= last7; |