Replace usage of rtl/memory.h in PDF Import with equivalent from string.h

Change-Id: I13f88bdfa6fc7d2b39fb2fd6a686b5364c20d6b5
This commit is contained in:
Arnaud Versini
2012-09-02 13:44:33 +02:00
parent fc971580c7
commit 1f08711bd1
3 changed files with 19 additions and 17 deletions

View File

@@ -49,6 +49,7 @@
#include <com/sun/star/io/TempFile.hpp> #include <com/sun/star/io/TempFile.hpp>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <string.h>
using namespace com::sun::star; using namespace com::sun::star;
@@ -256,7 +257,7 @@ bool FileEmitContext::write( const void* pBuf, unsigned int nLen )
return false; return false;
uno::Sequence< sal_Int8 > aSeq( nLen ); uno::Sequence< sal_Int8 > aSeq( nLen );
rtl_copyMemory( aSeq.getArray(), pBuf, nLen ); memcpy( aSeq.getArray(), pBuf, nLen );
m_xOut->writeBytes( aSeq ); m_xOut->writeBytes( aSeq );
return true; return true;
} }
@@ -560,7 +561,7 @@ bool checkDocChecksum( const rtl::OUString& rInPDFFileURL,
// open file and calculate actual checksum up to index nBytes // open file and calculate actual checksum up to index nBytes
sal_uInt8 nActualChecksum[ RTL_DIGEST_LENGTH_MD5 ]; sal_uInt8 nActualChecksum[ RTL_DIGEST_LENGTH_MD5 ];
rtl_zeroMemory( nActualChecksum, sizeof(nActualChecksum) ); memset( nActualChecksum, 0, sizeof(nActualChecksum) );
rtlDigest aActualDigest = rtl_digest_createMD5(); rtlDigest aActualDigest = rtl_digest_createMD5();
oslFileHandle aRead = NULL; oslFileHandle aRead = NULL;
oslFileError aErr = osl_File_E_None; oslFileError aErr = osl_File_E_None;

View File

@@ -46,6 +46,7 @@
#include <map> #include <map>
#include <stdio.h> #include <stdio.h>
#include <string.h>
using ::rtl::OUString; using ::rtl::OUString;
using ::rtl::OString; using ::rtl::OString;
@@ -1059,9 +1060,9 @@ struct PDFFileImplData
m_aCipher( NULL ), m_aCipher( NULL ),
m_aDigest( NULL ) m_aDigest( NULL )
{ {
rtl_zeroMemory( m_aOEntry, sizeof( m_aOEntry ) ); memset( m_aOEntry, 0, sizeof( m_aOEntry ) );
rtl_zeroMemory( m_aUEntry, sizeof( m_aUEntry ) ); memset( m_aUEntry, 0, sizeof( m_aUEntry ) );
rtl_zeroMemory( m_aDecryptionKey, sizeof( m_aDecryptionKey ) ); memset( m_aDecryptionKey, 0, sizeof( m_aDecryptionKey ) );
} }
~PDFFileImplData() ~PDFFileImplData()
@@ -1132,7 +1133,7 @@ static void pad_or_truncate_to_32( const OString& rStr, sal_Char* pBuffer )
if( nLen > 32 ) if( nLen > 32 )
nLen = 32; nLen = 32;
const sal_Char* pStr = rStr.getStr(); const sal_Char* pStr = rStr.getStr();
rtl_copyMemory( pBuffer, pStr, nLen ); memcpy( pBuffer, pStr, nLen );
int i = 0; int i = 0;
while( nLen < 32 ) while( nLen < 32 )
pBuffer[nLen++] = nPadString[i++]; pBuffer[nLen++] = nPadString[i++];
@@ -1170,7 +1171,7 @@ static sal_uInt32 password_to_key( const OString& rPwd, sal_uInt8* pOutKey, PDFF
sal_uInt32 nLen = pData->m_nKeyLength; sal_uInt32 nLen = pData->m_nKeyLength;
if( nLen > RTL_DIGEST_LENGTH_MD5 ) if( nLen > RTL_DIGEST_LENGTH_MD5 )
nLen = RTL_DIGEST_LENGTH_MD5; nLen = RTL_DIGEST_LENGTH_MD5;
rtl_copyMemory( pOutKey, nSum, nLen ); memcpy( pOutKey, nSum, nLen );
return nLen; return nLen;
} }
@@ -1180,10 +1181,10 @@ static bool check_user_password( const OString& rPwd, PDFFileImplData* pData )
bool bValid = false; bool bValid = false;
sal_uInt8 aKey[ENCRYPTION_KEY_LEN]; sal_uInt8 aKey[ENCRYPTION_KEY_LEN];
sal_uInt8 nEncryptedEntry[ENCRYPTION_BUF_LEN]; sal_uInt8 nEncryptedEntry[ENCRYPTION_BUF_LEN];
rtl_zeroMemory( nEncryptedEntry, sizeof(nEncryptedEntry) ); memset( nEncryptedEntry, 0, sizeof(nEncryptedEntry) );
sal_uInt32 nKeyLen = password_to_key( rPwd, aKey, pData, false ); sal_uInt32 nKeyLen = password_to_key( rPwd, aKey, pData, false );
// save (at this time potential) decryption key for later use // save (at this time potential) decryption key for later use
rtl_copyMemory( pData->m_aDecryptionKey, aKey, nKeyLen ); memcpy( pData->m_aDecryptionKey, aKey, nKeyLen );
if( pData->m_nStandardRevision == 2 ) if( pData->m_nStandardRevision == 2 )
{ {
// see PDF reference 1.4 Algorithm 3.4 // see PDF reference 1.4 Algorithm 3.4
@@ -1193,7 +1194,7 @@ static bool check_user_password( const OString& rPwd, PDFFileImplData* pData )
NULL, 0 ); NULL, 0 );
rtl_cipher_encodeARCFOUR( pData->m_aCipher, nPadString, sizeof( nPadString ), rtl_cipher_encodeARCFOUR( pData->m_aCipher, nPadString, sizeof( nPadString ),
nEncryptedEntry, sizeof( nEncryptedEntry ) ); nEncryptedEntry, sizeof( nEncryptedEntry ) );
bValid = (rtl_compareMemory( nEncryptedEntry, pData->m_aUEntry, 32 ) == 0); bValid = (memcmp( nEncryptedEntry, pData->m_aUEntry, 32 ) == 0);
} }
else if( pData->m_nStandardRevision == 3 ) else if( pData->m_nStandardRevision == 3 )
{ {
@@ -1218,7 +1219,7 @@ static bool check_user_password( const OString& rPwd, PDFFileImplData* pData )
nEncryptedEntry, 16, nEncryptedEntry, 16,
nEncryptedEntry, 16 ); // encrypt in place nEncryptedEntry, 16 ); // encrypt in place
} }
bValid = (rtl_compareMemory( nEncryptedEntry, pData->m_aUEntry, 16 ) == 0); bValid = (memcmp( nEncryptedEntry, pData->m_aUEntry, 16 ) == 0);
} }
return bValid; return bValid;
} }
@@ -1250,7 +1251,7 @@ bool PDFFile::setupDecryptionData( const OString& rPwd ) const
// see PDF reference 1.4 Algorithm 3.7 // see PDF reference 1.4 Algorithm 3.7
sal_uInt8 aKey[ENCRYPTION_KEY_LEN]; sal_uInt8 aKey[ENCRYPTION_KEY_LEN];
sal_uInt8 nPwd[ENCRYPTION_BUF_LEN]; sal_uInt8 nPwd[ENCRYPTION_BUF_LEN];
rtl_zeroMemory( nPwd, sizeof(nPwd) ); memset( nPwd, 0, sizeof(nPwd) );
sal_uInt32 nKeyLen = password_to_key( rPwd, aKey, m_pData, true ); sal_uInt32 nKeyLen = password_to_key( rPwd, aKey, m_pData, true );
if( m_pData->m_nStandardRevision == 2 ) if( m_pData->m_nStandardRevision == 2 )
{ {
@@ -1262,7 +1263,7 @@ bool PDFFile::setupDecryptionData( const OString& rPwd ) const
} }
else if( m_pData->m_nStandardRevision == 3 ) else if( m_pData->m_nStandardRevision == 3 )
{ {
rtl_copyMemory( nPwd, m_pData->m_aOEntry, 32 ); memcpy( nPwd, m_pData->m_aOEntry, 32 );
for( int i = 19; i >= 0; i-- ) for( int i = 19; i >= 0; i-- )
{ {
sal_uInt8 nTempKey[ENCRYPTION_KEY_LEN]; sal_uInt8 nTempKey[ENCRYPTION_KEY_LEN];
@@ -1381,7 +1382,7 @@ PDFFileImplData* PDFFile::impl_getData() const
{ {
OString aEnt = pString->getFilteredString(); OString aEnt = pString->getFilteredString();
if( aEnt.getLength() == 32 ) if( aEnt.getLength() == 32 )
rtl_copyMemory( m_pData->m_aOEntry, aEnt.getStr(), 32 ); memcpy( m_pData->m_aOEntry, aEnt.getStr(), 32 );
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
else else
{ {
@@ -1400,7 +1401,7 @@ PDFFileImplData* PDFFile::impl_getData() const
{ {
OString aEnt = pString->getFilteredString(); OString aEnt = pString->getFilteredString();
if( aEnt.getLength() == 32 ) if( aEnt.getLength() == 32 )
rtl_copyMemory( m_pData->m_aUEntry, aEnt.getStr(), 32 ); memcpy( m_pData->m_aUEntry, aEnt.getStr(), 32 );
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
else else
{ {

View File

@@ -41,7 +41,7 @@
#include <boost/spirit/include/classic_error_handling.hpp> #include <boost/spirit/include/classic_error_handling.hpp>
#include <boost/spirit/include/classic_file_iterator.hpp> #include <boost/spirit/include/classic_file_iterator.hpp>
#include <boost/bind.hpp> #include <boost/bind.hpp>
#include <string> #include <string.h>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <rtl/memory.h> #include <rtl/memory.h>
@@ -79,7 +79,7 @@ class StringEmitContext : public EmitContext
{ {
if( nOrigOffset+nLen < static_cast<unsigned int>(m_aBuf.getLength()) ) if( nOrigOffset+nLen < static_cast<unsigned int>(m_aBuf.getLength()) )
{ {
rtl_copyMemory( pBuf, m_aBuf.getStr()+nOrigOffset, nLen ); memcpy( pBuf, m_aBuf.getStr()+nOrigOffset, nLen );
return nLen; return nLen;
} }
return 0; return 0;