[Release] wrt-installer_0.0.90
[framework/web/wrt-installer.git] / src / jobs / widget_install / task_encrypt_resource.cpp
index cbcf554..71752e5 100644 (file)
  */
 #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>
@@ -74,8 +78,8 @@ void TaskEncryptResource::StepEncryptResource()
 {
     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());
 }
@@ -159,13 +163,19 @@ void TaskEncryptResource::EncryptFile(const std::string &fileName)
             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);