Author: truckman
Date: Wed Aug 31 16:12:32 2016
New Revision: 1758644

URL: http://svn.apache.org/viewvc?rev=1758644&view=rev
Log:
Fix -Wformat-security warnings.

There are a number of instances where the code calls *printf() to
print arbitrary strings and the string is passed as the format
argument to *printf().  Since these strings might contain %
conversion sequences, this is a security hazard.  Fix the problem
by printing the strings with a "%s" format.


Added:
    openoffice/trunk/main/icc/SampleICC-1.3.2.format-security.patch
    openoffice/trunk/main/icu/icu-format-security.patch
Modified:
    openoffice/trunk/main/cpputools/source/unoexe/unoexe.cxx
    openoffice/trunk/main/crashrep/source/unx/main.cxx
    openoffice/trunk/main/extensions/source/logging/consolehandler.cxx
    openoffice/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.cxx
    openoffice/trunk/main/icc/makefile.mk
    openoffice/trunk/main/icu/makefile.mk
    openoffice/trunk/main/rsc/source/prj/start.cxx
    openoffice/trunk/main/svtools/bmpmaker/bmp.cxx
    openoffice/trunk/main/svtools/bmpmaker/bmpsum.cxx
    openoffice/trunk/main/svtools/bmpmaker/g2g.cxx
    openoffice/trunk/main/vcl/source/fontsubset/cff.cxx
    openoffice/trunk/main/vcl/unx/generic/plugadapt/salplug.cxx

Modified: openoffice/trunk/main/cpputools/source/unoexe/unoexe.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/cpputools/source/unoexe/unoexe.cxx?rev=1758644&r1=1758643&r2=1758644&view=diff
==============================================================================
--- openoffice/trunk/main/cpputools/source/unoexe/unoexe.cxx (original)
+++ openoffice/trunk/main/cpputools/source/unoexe/unoexe.cxx Wed Aug 31 
16:12:32 2016
@@ -127,7 +127,7 @@ static sal_Bool s_quiet = false;
 static inline void out( const sal_Char * pText )
 {
     if (! s_quiet)
-        fprintf( stderr, pText );
+        fprintf( stderr, "%s", pText );
 }
 
//--------------------------------------------------------------------------------------------------
 static inline void out( const OUString & rText )
@@ -135,7 +135,7 @@ static inline void out( const OUString &
     if (! s_quiet)
     {
         OString aText( OUStringToOString( rText, RTL_TEXTENCODING_ASCII_US ) );
-        fprintf( stderr, aText.getStr() );
+        fprintf( stderr, "%s", aText.getStr() );
     }
 }
 

Modified: openoffice/trunk/main/crashrep/source/unx/main.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/crashrep/source/unx/main.cxx?rev=1758644&r1=1758643&r2=1758644&view=diff
==============================================================================
--- openoffice/trunk/main/crashrep/source/unx/main.cxx (original)
+++ openoffice/trunk/main/crashrep/source/unx/main.cxx Wed Aug 31 16:12:32 2016
@@ -364,7 +364,7 @@ bool SendHTTPRequest(
                                if ( g_bDebugMode )
                                {
                                        printf( "*** Sending HTTP request 
***\n\n" );
-                                       printf( buffer );
+                                       printf( "%s", buffer );
                                }
 
                                if ( SOCKET_ERROR != send( s, buffer, 
strlen(buffer), 0 ) )
@@ -401,7 +401,7 @@ bool SendHTTPRequest(
                                                if ( g_bDebugMode )
                                                        do
                                                        {
-                                                               printf( buffer 
);
+                                                               printf( "%s", 
buffer );
                                                                memset( buffer, 
0, sizeof(buffer) );
                                                        } while ( 0 < recv( s, 
buffer, sizeof(buffer), 0 ) );
                                        }

Modified: openoffice/trunk/main/extensions/source/logging/consolehandler.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/extensions/source/logging/consolehandler.cxx?rev=1758644&r1=1758643&r2=1758644&view=diff
==============================================================================
--- openoffice/trunk/main/extensions/source/logging/consolehandler.cxx 
(original)
+++ openoffice/trunk/main/extensions/source/logging/consolehandler.cxx Wed Aug 
31 16:12:32 2016
@@ -245,9 +245,9 @@ namespace logging
             return sal_False;
 
         if ( _rRecord.Level >= m_nThreshold )
-            fprintf( stderr, sEntry.getStr() );
+            fprintf( stderr, "%s", sEntry.getStr() );
         else
-            fprintf( stdout, sEntry.getStr() );
+            fprintf( stdout, "%s", sEntry.getStr() );
 
         return sal_True;
     }

Modified: openoffice/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.cxx?rev=1758644&r1=1758643&r2=1758644&view=diff
==============================================================================
--- openoffice/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.cxx 
(original)
+++ openoffice/trunk/main/fpicker/source/unx/gnome/SalGtkFilePicker.cxx Wed Aug 
31 16:12:32 2016
@@ -1047,6 +1047,7 @@ sal_Int16 SAL_CALL SalGtkFilePicker::exe
                                 GTK_DIALOG_MODAL,
                                                                
GTK_MESSAGE_QUESTION,
                                                                
GTK_BUTTONS_YES_NO,
+                                  "%s",
                                   OUStringToOString(
                                     aResProvider.getResString( 
FILE_PICKER_OVERWRITE ),
                                     RTL_TEXTENCODING_UTF8 ).getStr() );

Added: openoffice/trunk/main/icc/SampleICC-1.3.2.format-security.patch
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/icc/SampleICC-1.3.2.format-security.patch?rev=1758644&view=auto
==============================================================================
--- openoffice/trunk/main/icc/SampleICC-1.3.2.format-security.patch (added)
+++ openoffice/trunk/main/icc/SampleICC-1.3.2.format-security.patch Wed Aug 31 
16:12:32 2016
@@ -0,0 +1,21 @@
+diff -ur misc/SampleICC-1.3.2/IccProfLib/IccProfile.cpp 
misc/build/SampleICC-1.3.2/IccProfLib/IccProfile.cpp
+--- misc/SampleICC-1.3.2/IccProfLib/IccProfile.cpp     2007-08-20 
13:05:00.000000000 -0700
++++ misc/build/SampleICC-1.3.2/IccProfLib/IccProfile.cpp       2016-08-30 
22:11:34.440105000 -0700
+@@ -1155,7 +1155,7 @@
+ 
+   CIccInfo Info;
+   icChar buf[128];
+-  sprintf(buf, Info.GetSigName(m_Header.deviceClass));
++  sprintf(buf, "%s", Info.GetSigName(m_Header.deviceClass));
+   if (m_Header.deviceClass!=icSigInputClass && 
m_Header.deviceClass!=icSigDisplayClass) {
+     if (GetTag(icSigGrayTRCTag) || GetTag(icSigRedTRCTag) || 
GetTag(icSigGreenTRCTag) ||
+        GetTag(icSigBlueTRCTag) || GetTag(icSigRedColorantTag) || 
GetTag(icSigGreenColorantTag) ||
+@@ -1230,7 +1230,7 @@
+   for (i=m_Tags->begin(); i!=m_Tags->end(); i++) {
+     tagsig = i->TagInfo.sig;
+     typesig = i->pTag->GetType();
+-    sprintf(buf, Info.GetSigName(tagsig));
++    sprintf(buf, "%s", Info.GetSigName(tagsig));
+     if (!IsTypeValid(tagsig, typesig)) {
+       sReport += icValidateNonCompliantMsg;
+       sReport += buf;

Modified: openoffice/trunk/main/icc/makefile.mk
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/icc/makefile.mk?rev=1758644&r1=1758643&r2=1758644&view=diff
==============================================================================
--- openoffice/trunk/main/icc/makefile.mk (original)
+++ openoffice/trunk/main/icc/makefile.mk Wed Aug 31 16:12:32 2016
@@ -34,7 +34,7 @@ TARGET=icc
 
 TARFILE_NAME=SampleICC-1.3.2
 TARFILE_MD5=fdb27bfe2dbe2e7b57ae194d9bf36bab
-PATCH_FILES=$(TARFILE_NAME).patch
+PATCH_FILES=$(TARFILE_NAME).patch $(TARFILE_NAME).format-security.patch
 
 CONVERTFILES= \
        IccProfLib$/IccTagProfSeqId.h \

Added: openoffice/trunk/main/icu/icu-format-security.patch
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/icu/icu-format-security.patch?rev=1758644&view=auto
==============================================================================
--- openoffice/trunk/main/icu/icu-format-security.patch (added)
+++ openoffice/trunk/main/icu/icu-format-security.patch Wed Aug 31 16:12:32 2016
@@ -0,0 +1,12 @@
+diff -ur misc/icu/source/tools/ctestfw/uperf.cpp 
misc/build/icu/source/tools/ctestfw/uperf.cpp
+--- misc/icu/source/tools/ctestfw/uperf.cpp    2009-01-14 23:46:00.000000000 
-0800
++++ misc/build/icu/source/tools/ctestfw/uperf.cpp      2016-08-30 
22:19:11.917367000 -0700
+@@ -486,7 +486,7 @@
+         this->runIndexedTest( index, FALSE, name );
+         if (!name)
+             break;
+-        fprintf(stdout,name);
++        fprintf(stdout,"%s",name);
+         fprintf(stdout,"\n");
+         index++;
+     }while (name && (name[0] != 0));

Modified: openoffice/trunk/main/icu/makefile.mk
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/icu/makefile.mk?rev=1758644&r1=1758643&r2=1758644&view=diff
==============================================================================
--- openoffice/trunk/main/icu/makefile.mk (original)
+++ openoffice/trunk/main/icu/makefile.mk Wed Aug 31 16:12:32 2016
@@ -42,7 +42,8 @@ TARFILE_MD5=
 .ENDIF
 TARFILE_ROOTDIR=icu
 
-PATCH_FILES=${TARFILE_NAME}.patch icu-mp.patch icu-win-layoutex.patch
+PATCH_FILES=${TARFILE_NAME}.patch icu-mp.patch icu-win-layoutex.patch \
+       icu-format-security.patch
 
 # ADDITIONAL_FILES=
 

Modified: openoffice/trunk/main/rsc/source/prj/start.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/rsc/source/prj/start.cxx?rev=1758644&r1=1758643&r2=1758644&view=diff
==============================================================================
--- openoffice/trunk/main/rsc/source/prj/start.cxx (original)
+++ openoffice/trunk/main/rsc/source/prj/start.cxx Wed Aug 31 16:12:32 2016
@@ -254,7 +254,7 @@ static sal_Bool CallRsc2( ByteString aRs
 #ifdef OS2
                fprintf( fRspFile, "%s\n", aSrsName.GetBuffer() );
 #else
-               fprintf( fRspFile, aSrsName.GetBuffer() );
+               fprintf( fRspFile, "%s", aSrsName.GetBuffer() );
 #endif
 
                pString = pInputList->First();

Modified: openoffice/trunk/main/svtools/bmpmaker/bmp.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svtools/bmpmaker/bmp.cxx?rev=1758644&r1=1758643&r2=1758644&view=diff
==============================================================================
--- openoffice/trunk/main/svtools/bmpmaker/bmp.cxx (original)
+++ openoffice/trunk/main/svtools/bmpmaker/bmp.cxx Wed Aug 31 16:12:32 2016
@@ -157,7 +157,7 @@ void BmpApp::Message( const String& rTex
 
        ByteString aText( rText, RTL_TEXTENCODING_UTF8 );
        aText.Append( "\r\n" );
-       fprintf( stderr, aText.GetBuffer() );
+       fprintf( stderr, "%s", aText.GetBuffer() );
 }
 
 // 
-----------------------------------------------------------------------------

Modified: openoffice/trunk/main/svtools/bmpmaker/bmpsum.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svtools/bmpmaker/bmpsum.cxx?rev=1758644&r1=1758643&r2=1758644&view=diff
==============================================================================
--- openoffice/trunk/main/svtools/bmpmaker/bmpsum.cxx (original)
+++ openoffice/trunk/main/svtools/bmpmaker/bmpsum.cxx Wed Aug 31 16:12:32 2016
@@ -160,7 +160,7 @@ void BmpSum::Message( const String& rTex
 
        ByteString aText( rText, RTL_TEXTENCODING_UTF8 );
        aText.Append( "\r\n" );
-       fprintf( stderr, aText.GetBuffer() );
+       fprintf( stderr, "%s", aText.GetBuffer() );
 }
 
 // 
-----------------------------------------------------------------------------

Modified: openoffice/trunk/main/svtools/bmpmaker/g2g.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/svtools/bmpmaker/g2g.cxx?rev=1758644&r1=1758643&r2=1758644&view=diff
==============================================================================
--- openoffice/trunk/main/svtools/bmpmaker/g2g.cxx (original)
+++ openoffice/trunk/main/svtools/bmpmaker/g2g.cxx Wed Aug 31 16:12:32 2016
@@ -121,7 +121,7 @@ void G2GApp::Message( const String& rTex
 
        ByteString aText( rText, RTL_TEXTENCODING_UTF8 );
        aText.Append( "\r\n" );
-       fprintf( stderr, aText.GetBuffer() );
+       fprintf( stderr, "%s", aText.GetBuffer() );
 }
 
 // 
-----------------------------------------------------------------------------

Modified: openoffice/trunk/main/vcl/source/fontsubset/cff.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/vcl/source/fontsubset/cff.cxx?rev=1758644&r1=1758643&r2=1758644&view=diff
==============================================================================
--- openoffice/trunk/main/vcl/source/fontsubset/cff.cxx (original)
+++ openoffice/trunk/main/vcl/source/fontsubset/cff.cxx Wed Aug 31 16:12:32 2016
@@ -2062,7 +2062,7 @@ void Type1Emitter::emitValVector( const
                return;
 
        // emit the line head
-       mpPtr += sprintf( mpPtr, pLineHead);
+       mpPtr += sprintf( mpPtr, "%s", pLineHead);
        // emit the vector values
        ValVector::value_type aVal = 0;
        for( ValVector::const_iterator it = rVector.begin();;) {
@@ -2075,7 +2075,7 @@ void Type1Emitter::emitValVector( const
        // emit the last value
        mpPtr += dbl2str( mpPtr, aVal);
        // emit the line tail
-       mpPtr += sprintf( mpPtr, pLineTail);
+       mpPtr += sprintf( mpPtr, "%s", pLineTail);
 }
 
 // --------------------------------------------------------------------

Modified: openoffice/trunk/main/vcl/unx/generic/plugadapt/salplug.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/vcl/unx/generic/plugadapt/salplug.cxx?rev=1758644&r1=1758643&r2=1758644&view=diff
==============================================================================
--- openoffice/trunk/main/vcl/unx/generic/plugadapt/salplug.cxx (original)
+++ openoffice/trunk/main/vcl/unx/generic/plugadapt/salplug.cxx Wed Aug 31 
16:12:32 2016
@@ -276,7 +276,7 @@ void SalAbort( const XubString& rErrorTe
        if( !rErrorText.Len() )
                std::fprintf( stderr, "Application Error" );
        else
-               std::fprintf( stderr, ByteString( rErrorText, 
gsl_getSystemTextEncoding() ).GetBuffer() );
+               std::fprintf( stderr, "%s", ByteString( rErrorText, 
gsl_getSystemTextEncoding() ).GetBuffer() );
        abort();
 }
 


Reply via email to