[Libreoffice-commits] core.git: Branch 'libreoffice-6-0' - vcl/source

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


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

New commits:
commit 80785f935455f3e740c57febc33410f1ee81f12a
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/46642
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/vcl/source/gdi/jobset.cxx b/vcl/source/gdi/jobset.cxx
index cc8712a48615..fe7cbb2936d9 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?
@@ -345,9 +347,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( JOBSET_FILE605_SYSTEM );


More information about the Libreoffice-commits mailing list