From a322e61b51a04e189618e1d0c8c17f9c080a3d1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Mon, 2 Dec 2019 13:03:48 +0000 Subject: [PATCH] ofz#19207 check max strlen possible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I5fe9fde240ef375d9de097dda47953320ecc758d Reviewed-on: https://gerrit.libreoffice.org/84219 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- filter/source/graphicfilter/icgm/class7.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/filter/source/graphicfilter/icgm/class7.cxx b/filter/source/graphicfilter/icgm/class7.cxx index c85e5284e026..8c2478a308ae 100644 --- a/filter/source/graphicfilter/icgm/class7.cxx +++ b/filter/source/graphicfilter/icgm/class7.cxx @@ -127,9 +127,11 @@ void CGM::ImplDoClass7() nAttributes >>= 12; pTextEntry->nAttributes = nAttributes; pAppData += 8; - sal_uInt32 nLen = strlen( reinterpret_cast( pAppData ) ) + 1; - pTextEntry->pText = new char[ nLen ]; + auto nMaxLen = mpEndValidSource - pAppData; + sal_uInt32 nLen = strnlen(reinterpret_cast(pAppData), nMaxLen); + pTextEntry->pText = new char[nLen + 1]; memcpy( pTextEntry->pText, pAppData, nLen ); + pTextEntry->pText[nLen] = 0; pAppData += nLen; mpChart->InsertTextEntry( std::move(pTextEntry) );