Commit 89b384ab authored by ElenaSubbotina's avatar ElenaSubbotina

fix derypt file

parent f54baf3a
...@@ -483,26 +483,27 @@ namespace DocFileFormat ...@@ -483,26 +483,27 @@ namespace DocFileFormat
delete storageOut; delete storageOut;
return false; return false;
} }
DecryptStream( 0, "/", storageIn, storageOut, Decryptor);
std::list<std::string> listStream = storageIn->entries();
//std::list<std::string> listStream = storageIn->entries();
for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
{ //for (std::list<std::string>::iterator it = listStream.begin(); it != listStream.end(); it++)
if (storageIn->isDirectory(*it)) //{
{ // if (storageIn->isDirectory(*it))
std::list<std::string> list_entry = storageIn->GetAllStreams(*it); // {
// std::list<std::string> list_entry = storageIn->GetAllStreams(*it);
for (std::list<std::string>::iterator it2 = list_entry.begin(); it2 != list_entry.end(); it2++) //
{ // for (std::list<std::string>::iterator it2 = list_entry.begin(); it2 != list_entry.end(); it2++)
DecryptStream(Decryptor, *it2, storageIn, storageOut); // {
} // DecryptStream(Decryptor, *it2, storageIn, storageOut);
} // }
else // }
{ // else
DecryptStream(Decryptor, *it, storageIn, storageOut); // {
} // DecryptStream(Decryptor, *it, storageIn, storageOut);
// }
}
//}
storageOut->close(); storageOut->close();
delete storageOut; delete storageOut;
...@@ -525,34 +526,28 @@ namespace DocFileFormat ...@@ -525,34 +526,28 @@ namespace DocFileFormat
} }
return true; return true;
} }
bool WordDocument::CopyStream (std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut) void WordDocument::DecryptStream( int level, std::string path, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
{ {
POLE::Stream *stream = new POLE::Stream(storageIn, streamName); std::list<std::string> entries;
if (!stream) return false; entries = storageIn->entries( path );
stream->seek(0); std::list<std::string>::iterator it;
int sz_stream = stream->size(); for( it = entries.begin(); it != entries.end(); ++it )
{
POLE::Stream *streamNew = new POLE::Stream(storageOut, streamName, true, sz_stream); std::string name = *it;
if (!streamNew) return false; std::string fullname = path + name;
unsigned char* data_stream = new unsigned char[sz_stream]; if( storageIn->isDirectory( fullname ) )
stream->read(data_stream, sz_stream); {
DecryptStream( level + 1, fullname + "/", storageIn, storageOut, Decryptor );
streamNew->write(data_stream, sz_stream); }
else
RELEASEARRAYOBJECTS(data_stream); {
DecryptStream(fullname, storageIn, storageOut, Decryptor );
streamNew->flush(); }
}
delete streamNew;
delete stream;
return true;
} }
bool WordDocument::DecryptStream(std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor)
bool WordDocument::DecryptStream(CRYPT::Decryptor* Decryptor, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut)
{ {
POLE::Stream *stream = new POLE::Stream(storageIn, streamName); POLE::Stream *stream = new POLE::Stream(storageIn, streamName);
if (!stream) return false; if (!stream) return false;
...@@ -567,9 +562,9 @@ namespace DocFileFormat ...@@ -567,9 +562,9 @@ namespace DocFileFormat
stream->read(data_stream, size_stream); stream->read(data_stream, size_stream);
unsigned char* data_store = NULL; unsigned char* data_store = NULL;
int size_data_store = 0; int size_data_store = 0;
if ("WordDocument" == streamName) if ( std::wstring::npos != streamName.find("WordDocument") )
{ {
size_data_store = 68; size_data_store = 68;
data_store = new unsigned char[size_data_store]; data_store = new unsigned char[size_data_store];
......
...@@ -102,9 +102,10 @@ namespace DocFileFormat ...@@ -102,9 +102,10 @@ namespace DocFileFormat
private: private:
bool DecryptOfficeFile (CRYPT::Decryptor* Decryptor); bool DecryptOfficeFile (CRYPT::Decryptor* Decryptor);
bool DecryptStream (CRYPT::Decryptor* Decryptor, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut);
bool CopyStream (std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut); bool DecryptStream (std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
void DecryptStream (int level, std::string streamName, POLE::Storage * storageIn, POLE::Storage * storageOut, CRYPT::Decryptor* Decryptor);
inline StructuredStorageReader* GetStorage() const inline StructuredStorageReader* GetStorage() const
{ {
return m_pStorage; return m_pStorage;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment