diff --git a/packing_tool/frameworks/BUILD.gn b/packing_tool/frameworks/BUILD.gn index 0c027908c471c84cabf7b98ec3df849a92b4b799..bcc9b059e7428fb4d3a08814ca314202e9980cdd 100644 --- a/packing_tool/frameworks/BUILD.gn +++ b/packing_tool/frameworks/BUILD.gn @@ -63,7 +63,6 @@ ohos_executable("ohos_packing_tool") { configs = [] cflags = [] external_deps = [ - "hilog:libhilog", "openssl:libcrypto_shared", "zlib:libz", ] @@ -72,10 +71,19 @@ ohos_executable("ohos_packing_tool") { "//build/lite/config/component/cJSON:cjson_static", "//third_party/bounds_checking_function:libsec_static", ] + if (ohos_kernel_type == "liteos_m") { + include_dirs = [ "//base/hiviewdfx/hilog_lite/interfaces/native/kits" ] + deps += [ "//base/hiviewdfx/hilog_lite/frameworks/mini:hilog_lite" ] + } else { + include_dirs = + [ "//base/hiviewdfx/hilog_lite/interfaces/native/innerkits" ] + deps += [ "//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared" ] + } } else { external_deps += [ "bounds_checking_function:libsec_static", "cJSON:cjson_static", + "hilog:libhilog", ] } install_enable = false diff --git a/packing_tool/frameworks/src/zip_wrapper.cpp b/packing_tool/frameworks/src/zip_wrapper.cpp index ca437fe70d464a698a10932243d3b7a4c6dcd100..e018e7dfeb9385681989a2c2826eae298417dcbf 100644 --- a/packing_tool/frameworks/src/zip_wrapper.cpp +++ b/packing_tool/frameworks/src/zip_wrapper.cpp @@ -175,7 +175,7 @@ int32_t ZipWrapper::AddFileToZip(const fs::path &fsFilePath, const fs::path &fsZ int32_t result = ZIP_ERR_SUCCESS; if (fs::file_size(fsFilePath) > 0) { result = ZIP_ERR_SUCCESS; - char buffer[MAX_ZIP_BUFFER_SIZE]; + char buffer[MAX_ZIP_BUFFER_SIZE] = { 0 }; while (!file.eof()) { file.read(buffer, sizeof(buffer)); if (file.fail() && !file.eof()) { @@ -183,11 +183,14 @@ int32_t ZipWrapper::AddFileToZip(const fs::path &fsFilePath, const fs::path &fsZ break; } auto bytesRead = file.gcount(); - if (bytesRead <= 0) { + if (bytesRead < 0) { LOGE("read file bytes error![filePath=%s][bytesRead=%u]", fsFilePath.c_str(), bytesRead); result = ZIP_ERR_FAILURE; break; } + if (bytesRead == 0) { + break; + } if (zipWriteInFileInZip(zipFile_, buffer, bytesRead) < 0) { LOGE("write file in zip failed!"); result = ZIP_ERR_FAILURE;