Ver Fonte

Z991239-5772 #comment 优化加密文件自定义文件头文件大小保存方式

80274480 há 1 ano atrás
pai
commit
2948dbda13

+ 3 - 3
Other/libfilecryption/fileanalysis.cpp

@@ -76,9 +76,9 @@ int get_srcfile_hash(char* phash, uint32_t ulen, const char* pfilename)
 }
 
 
-unsigned long get_srcfile_size(const char* pfilename)
+uint32_t get_srcfile_size(const char* pfilename)
 {
-	unsigned long usize = 0;
+	uint32_t usize = 0;
 	if (NULL == pfilename){
 		return usize;
 	}
@@ -86,7 +86,7 @@ unsigned long get_srcfile_size(const char* pfilename)
 	FILE* pFile = fopen(pfilename, "rb");
 	if (pFile){
 		fseek(pFile, 0, SEEK_END);
-		usize = ftell(pFile);
+		usize = (uint32_t)ftell(pFile);
 		fclose(pFile);
 	}
 

+ 1 - 1
Other/libfilecryption/fileanalysis.h

@@ -14,7 +14,7 @@
 int get_srcfile_name(char* pname, uint32_t ulen, const char* pfilename);
 int get_srcfile_format(char* pformat, uint32_t ulen, const char* pfilename);
 int get_srcfile_hash(char* phash, uint32_t ulen, const char* pfilename);
-unsigned long get_srcfile_size(const char* pfilename);
+uint32_t get_srcfile_size(const char* pfilename);
 int get_encrytion_filename(char* strbuffer, uint32_t ulen, bool bencname, const char* strprefix, uint32_t uprefixlen, const char* pfilename);
 int get_decrytion_filename(char* strbuffer, uint32_t ulen, const char* strprefix, uint32_t uprefixlen, const char* pfilename);
 int SM4EncECBMode(unsigned char key[16], unsigned char *input, int length, unsigned char *output, int *output_len);

+ 1 - 1
Other/libfilecryption/filecryption.cpp

@@ -113,7 +113,7 @@ static int encrypt_mp4_file(char* poutfilename, char* phead, uint32_t uheaderlen
 	}
 
 	fseek(pSrcFile, 0, SEEK_END);
-	unsigned int usrcfilelen = ftell(pSrcFile);
+	uint32_t usrcfilelen = (uint32_t)ftell(pSrcFile);
 	rewind(pSrcFile);
 	safe_log(pcallback, FILECRYPT_LOG_INFO, "src file length is %u.", usrcfilelen);
 

+ 2 - 2
Other/libfilecryption/mp4info.cpp

@@ -16,9 +16,9 @@ static unsigned int big_to_small_endian_32bit(unsigned int const big)
 
 
 //ftyp, free, mdat box not encryt
-unsigned int get_noencrypt_boxs_size(FILE* pSrcFile, const filecryption_callback_t* pcallback, bool bgetmoov)
+uint32_t get_noencrypt_boxs_size(FILE* pSrcFile, const filecryption_callback_t* pcallback, bool bgetmoov)
 {
-	unsigned int uret = 0;
+	uint32_t uret = 0;
 	if (NULL == pSrcFile) {
 		return uret;
 	}

+ 5 - 5
Other/libfilecryption/rvcfileheader.cpp

@@ -33,9 +33,9 @@ int constrcut_rvc_file_header(char* pbuffer, uint32_t* ulen, const char* pfilena
 	}
 
 	//5. 源文件文件大小
-	unsigned long usize = get_srcfile_size(pfilename);
-	memcpy(pbuffer+udatalen, &usize, sizeof(unsigned long));
-	udatalen += sizeof(unsigned long);
+	uint32_t usize = get_srcfile_size(pfilename);
+	memcpy(pbuffer+udatalen, &usize, sizeof(uint32_t));
+	udatalen += sizeof(uint32_t);
 
 	//6. 源文件文件名
 	char strname[MAX_PATH] = {0};
@@ -80,8 +80,8 @@ int get_rvc_file_header_info(rvc_fileheader_t* pdata, char* pheadbuffer, uint32_
 		return iret;
 	}
 	//5. 源文件文件大小
-	memcpy(&pdata->usrcfilelen, pheadbuffer+uindex, sizeof(unsigned long));
-	uindex += sizeof(unsigned long);
+	memcpy(&pdata->usrcfilelen, pheadbuffer+uindex, sizeof(uint32_t));
+	uindex += sizeof(uint32_t);
 	//6. 源文件文件名
 	if (0 == get_tag_value_from_buffer((char*)pdata->strsrcfilename, MAX_PATH, pheadbuffer+uindex, ulen - uindex)){
 		uindex += (strlen(pdata->strsrcfilename) + sizeof(uint32_t));

+ 1 - 1
Other/libfilecryption/rvcfileheader.h

@@ -45,7 +45,7 @@ typedef struct rvc_fileheader_s{
 	size_t uheadlen;
 	char strcryptver[RVC_CRYPTION_VER_FLAG_LEN];
 	unsigned char strhash[RVC_FILE_HASH_LEN];
-	unsigned long usrcfilelen;
+	uint32_t usrcfilelen;
 	char strsrcfilename[MAX_PATH];
 	char strsrcfileformat[MAX_PATH];
 }rvc_fileheader_t;