[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - vcl/source

Caolán McNamara caolanm at redhat.com
Mon Dec 18 13:25:09 UTC 2017


 vcl/source/gdi/jobset.cxx |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit 385fe413094fa56278ce3a21fa42f091496962be
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Sun Dec 17 13:57:46 2017 +0000

    ofz: ensure null termination
    
    Change-Id: I6b6b0763e85a41d03f9e03c6abc17c6c311f6519
    Reviewed-on: https://gerrit.libreoffice.org/46643
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx
index 57c02b95b557..0e2e3c96a372 100644
--- a/vcl/source/gdi/jobset.cxx
+++ b/vcl/source/gdi/jobset.cxx
@@ -256,7 +256,9 @@ SvStream& ReadJobSetup( SvStream& rIStream, JobSetup& rJobSetup )
 
             ImplJobSetup& rJobData = rJobSetup.ImplGetData();
 
+            pData->cPrinterName[SAL_N_ELEMENTS(pData->cPrinterName) - 1] = 0;
             rJobData.SetPrinterName( OStringToOUString(pData->cPrinterName, aStreamEncoding) );
+            pData->cDriverName[SAL_N_ELEMENTS(pData->cDriverName) - 1] = 0;
             rJobData.SetDriver( OStringToOUString(pData->cDriverName, aStreamEncoding) );
 
             // Are these our new JobSetup files?
@@ -347,9 +349,9 @@ SvStream& WriteJobSetup( SvStream& rOStream, const JobSetup& rJobSetup )
             ImplOldJobSetupData aOldData;
             memset( &aOldData, 0, sizeof( aOldData ) );
             OString aPrnByteName(OUStringToOString(rJobData.GetPrinterName(), RTL_TEXTENCODING_UTF8));
-            strncpy( aOldData.cPrinterName, aPrnByteName.getStr(), 63 );
+            strncpy(aOldData.cPrinterName, aPrnByteName.getStr(), SAL_N_ELEMENTS(aOldData.cPrinterName) - 1);
             OString aDriverByteName(OUStringToOString(rJobData.GetDriver(), RTL_TEXTENCODING_UTF8));
-            strncpy( aOldData.cDriverName, aDriverByteName.getStr(), 31 );
+            strncpy(aOldData.cDriverName, aDriverByteName.getStr(), SAL_N_ELEMENTS(aOldData.cDriverName) - 1);
             int nPos = rOStream.Tell();
             rOStream.WriteUInt16( 0 );
             rOStream.WriteUInt16( nSystem );


More information about the Libreoffice-commits mailing list