*/
#include "task_encrypt_resource.h"
+#undef __USE_FILE_OFFSET64
+
#include <unistd.h>
#include <string>
#include <sys/stat.h>
#include <fts.h>
+#include <string.h>
+#include <errno.h>
#include <dpl/log/log.h>
#include <dpl/errno_string.h>
{
LogDebug("Step Encrypt resource");
m_resEnc = new ResourceEncryptor;
- m_resEnc->CreateEncryptionKey(DPL::ToUTF8String(*m_context.
- widgetConfig.pkgname));
+ m_resEnc->CreateEncryptionKey(DPL::ToUTF8String(m_context.
+ widgetConfig.pkgName));
EncryptDirectory(m_context.locations->getTemporaryRootDir());
}
memset(readBuf, 0, fileSize);
memset(outEncBuf, 0, blockSize);
- fread(readBuf, sizeof(unsigned char), fileSize, resFp);
+ ret = fread(readBuf, sizeof(unsigned char), fileSize, resFp);
+ if (ret!=fileSize){
+ LogError("Failed to read ecryption buffer with error: " << strerror(errno) );
+ fclose(resFp);
+ return;
+ }
m_resEnc->EncryptChunk(readBuf, outEncBuf, fileSize);
FILE* encFp = fopen(encFile.c_str(), "w");
if (NULL == encFp) {
LogError("Failed to open ecryption file");
+ fclose(resFp);
return;
}
fwrite(outEncBuf, sizeof(unsigned char), blockSize, encFp);