summaryrefslogtreecommitdiff
path: root/cpputil
diff options
context:
space:
mode:
authorEKR <ekr@rtfm.com>2017-09-04 04:35:10 -0700
committerEKR <ekr@rtfm.com>2017-09-04 04:35:10 -0700
commitdc86cbb83fb487cdd5de84703bc031d0d9df0d51 (patch)
tree66890eaa7ee0d4546ed4e4310dd2ece0bbc79f8e /cpputil
parent0ec9a2703f77ec33765b318cc1ec519206faec26 (diff)
downloadnss-hg-dc86cbb83fb487cdd5de84703bc031d0d9df0d51.tar.gz
Bug 1316231 - DTLS 1.3 ACKs. r=mt
Diffstat (limited to 'cpputil')
-rw-r--r--cpputil/databuffer.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/cpputil/databuffer.h b/cpputil/databuffer.h
index 287cbb2a7..d229a360a 100644
--- a/cpputil/databuffer.h
+++ b/cpputil/databuffer.h
@@ -100,8 +100,8 @@ class DataBuffer {
// This can't use the same trick as Write(), since we might be reading from a
// smaller data source.
- bool Read(size_t index, size_t count, uint32_t* val) const {
- assert(count < sizeof(uint32_t));
+ bool Read(size_t index, size_t count, uint64_t* val) const {
+ assert(count <= sizeof(uint64_t));
assert(val);
if ((index > len()) || (count > (len() - index))) {
return false;
@@ -113,6 +113,18 @@ class DataBuffer {
return true;
}
+ // Overload because we have a lot of places where we are doing uint32_t
+ bool Read(size_t index, size_t count, uint32_t* val) const {
+ assert(count <= sizeof(uint32_t));
+ uint64_t tmp;
+
+ if (!Read(index, count, &tmp)) {
+ return false;
+ }
+ *val = tmp & 0xffffffff;
+ return true;
+ }
+
// Starting at |index|, remove |remove| bytes and replace them with the
// contents of |buf|.
void Splice(const DataBuffer& buf, size_t index, size_t remove = 0) {