#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>
memset(readBuf, 0, fileSize);
memset(outEncBuf, 0, blockSize);
- fread(readBuf, sizeof(unsigned char), fileSize, resFp);
- fclose(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);
+
+ fclose(resFp);
fclose(encFp);
LogDebug("Success to encrypt file");