From 3abe0470b747868589dbe04e1ed03739ce502e74 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 28 Feb 2022 09:15:10 +0000 Subject: ensure null terminator LIBREOFFICE-WB8DT2Q9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130668 Reviewed-by: Michael Stahl Tested-by: Jenkins (cherry picked from commit 4b6956ca146f25b746f63c176b377d3c15d204ff) Change-Id: I98529325bbd3ff475ba84b4991eb17240440df4b (cherry picked from commit 918c4a49fa841f0d234b18234d946684fe6378af) --- sc/source/filter/lotus/op.cxx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx index 7033f6da0550..40f01ab37556 100644 --- a/sc/source/filter/lotus/op.cxx +++ b/sc/source/filter/lotus/op.cxx @@ -583,14 +583,9 @@ void OP_SheetName123(LotusContext& rContext, SvStream& rStream, sal_uInt16 nLeng SCTAB nSheetNum = static_cast(nDummy); rContext.pDoc->MakeTable(nSheetNum); - ::std::vector sSheetName; - sSheetName.reserve(nLength-4); - for (sal_uInt16 i = 4; i < nLength; ++i) - { - sal_Char c; - rStream.ReadChar( c ); - sSheetName.push_back(c); - } + const size_t nStrLen = nLength - 4; + std::vector sSheetName(nStrLen + 1); + sSheetName[rStream.ReadBytes(sSheetName.data(), nStrLen)] = 0; if (!sSheetName.empty()) { -- cgit