From 7441ce5b513bf0e1d53ab8e265ab4b84bf810ffc Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Sat, 28 Feb 2015 23:49:07 +0200 Subject: [PATCH] sstable: fix buffer overflow in TOC boost::split() expects either a NUL terminated string or a proper container. We give it neither. Fix by wrapping the buffer in a string_view, which tells split() what size the string is. --- sstables/sstables.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sstables/sstables.cc b/sstables/sstables.cc index e021e91379..6ec6ba5919 100644 --- a/sstables/sstables.cc +++ b/sstables/sstables.cc @@ -329,7 +329,7 @@ future<> sstable::read_toc() { throw malformed_sstable_exception("SSTable too big: " + to_sstring(size) + " bytes."); } - auto buf = bufptr.get(); + std::experimental::string_view buf(bufptr.get(), size); std::vector comps; boost::split(comps , buf, boost::is_any_of("\n"));