Subversion Repositories spk

Rev

Rev 227 | Rev 308 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 227 Rev 229
Line 504... Line 504...
504
		Utils::WString str = c->sFile;
504
		Utils::WString str = c->sFile;
505
		cat += str.findReplace(L"/", L"\\").findReplace(L"\\\\", L"\\") + L" " + (long)c->lSize + L"\n";
505
		cat += str.findReplace(L"/", L"\\").findReplace(L"\\\\", L"\\") + L" " + (long)c->lSize + L"\n";
506
	}
506
	}
507
 
507
 
508
	if ( !cat.length() ) return false;
508
	if ( !cat.length() ) return false;
-
 
509
 
-
 
510
	Utils::String str = cat.toString();
509
 
511
 
510
	// make sure the len is in multiples of 5, otherwise decryptData could cause heap problems
512
	// make sure the len is in multiples of 5, otherwise decryptData could cause heap problems
511
	size_t len = cat.length() + ((cat.length() % 5) ? 5 - (cat.length() % 5) : 0);
513
	size_t len = str.length() + ((str.length() % 5) ? 5 - (str.length() % 5) : 0);
512
 
514
 
513
	bool ret = false;
515
	bool ret = false;
514
	try {
516
	try {
515
		unsigned char *data = new unsigned char[len + 1];
517
		unsigned char *data = new unsigned char[len + 1];
516
		memcpy(data, cat.c_str(), cat.length() * sizeof(unsigned char));
518
		memcpy(data, str.c_str(), str.length() * sizeof(unsigned char));
517
		for ( size_t i = len; i >= cat.length(); i-- ) data[i] = '\0';
519
		for ( size_t i = len; i >= str.length(); i-- ) data[i] = '\0';
518
		this->DecryptData(data, len);
520
		this->DecryptData(data, len);
519
 
521
 
520
		bool ret = m_fCatFile.write(data, cat.length());
522
		bool ret = m_fCatFile.write(data, str.length());
521
		delete []data;
523
		delete []data;
522
	}
524
	}
523
	catch(std::exception &e) {
525
	catch(std::exception &e) {
524
		CLog::logf(CLog::Log_IO, 2, L"CCatFile::WriteCatFile() unable to malloc, %d (%hs)", len + 1, e.what());
526
		CLog::logf(CLog::Log_IO, 2, L"CCatFile::WriteCatFile() unable to malloc, %d (%hs)", len + 1, e.what());
525
		return false;
527
		return false;