aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFarid Zakaria <fmzakari@google.com>2021-11-18 04:00:19 +0000
committerFarid Zakaria <fmzakari@google.com>2021-11-18 04:05:25 +0000
commitbc14465e08a286f8bc3b1e47e70372352b64bd2c (patch)
tree1503e9f5a2f3b7ec9b479e11dbf605ac53b49591
parent480c883f363912df611c545b05ae0f6f1b9a6c61 (diff)
Fix stack buffer overflow
Fix a stack buffer overflow found by running MemorySanitizer.
-rw-r--r--src/libstore/references.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstore/references.cc b/src/libstore/references.cc
index c369b14ac..bb9590acb 100644
--- a/src/libstore/references.cc
+++ b/src/libstore/references.cc
@@ -54,7 +54,7 @@ void RefScanSink::operator () (std::string_view data)
fragment, so search in the concatenation of the tail of the
previous fragment and the start of the current fragment. */
auto s = tail;
- s.append(data.data(), refLength);
+ s.append(data.data(), std::min(data.size(), refLength));
search(s, hashes, seen);
search(data, hashes, seen);