From c0bcfb7d921b7da5b7ec3eabe5ece0927b768217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=85=89=E8=80=80?= Date: Wed, 10 Sep 2025 16:16:53 +0800 Subject: [PATCH 1/3] test0901-001 update001 Signed-off-by heguangyao MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 何光耀 --- frameworks/innerkitsimpl/codec/src/image_source.cpp | 10 +++++----- frameworks/innerkitsimpl/utils/src/image_utils.cpp | 10 ++++++++-- .../src/texture_encode/image_compressor.cpp | 9 +++++++-- .../libs/image/libpngplugin/src/png_decoder.cpp | 4 ++++ plugins/manager/src/common/platform_adp.cpp | 12 +++++++++++- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/frameworks/innerkitsimpl/codec/src/image_source.cpp b/frameworks/innerkitsimpl/codec/src/image_source.cpp index 68f077254..667e5b077 100644 --- a/frameworks/innerkitsimpl/codec/src/image_source.cpp +++ b/frameworks/innerkitsimpl/codec/src/image_source.cpp @@ -685,7 +685,7 @@ static inline bool IsDensityChange(int32_t srcDensity, int32_t wantDensity) static inline int32_t GetScalePropByDensity(int32_t prop, int32_t srcDensity, int32_t wantDensity) { bool cond = srcDensity != 0; - int32_t ret = (prop * wantDensity + (srcDensity >> 1)) / srcDensity; + int32_t ret = (prop * wantDensity + (srcDensity / 2)) / srcDensity; CHECK_ERROR_RETURN_RET(cond, ret); return prop; } @@ -4337,10 +4337,10 @@ bool ImageSource::ApplyGainMap(ImageHdrType hdrType, DecodeContext& baseCtx, Dec void ImageSource::SetVividMetaColor(HdrMetadata& metadata, CM_ColorSpaceType base, CM_ColorSpaceType gainmap, CM_ColorSpaceType hdr) { - metadata.extendMeta.baseColorMeta.baseColorPrimary = base & 0xFF; - metadata.extendMeta.gainmapColorMeta.enhanceDataColorPrimary = gainmap & 0xFF; - metadata.extendMeta.gainmapColorMeta.combineColorPrimary = gainmap & 0xFF; - metadata.extendMeta.gainmapColorMeta.alternateColorPrimary = hdr & 0xFF; + metadata.extendMeta.baseColorMeta.baseColorPrimary = static_cast(base) & 0xFF; + metadata.extendMeta.gainmapColorMeta.enhanceDataColorPrimary = static_cast(gainmap) & 0xFF; + metadata.extendMeta.gainmapColorMeta.combineColorPrimary = static_cast(gainmap) & 0xFF; + metadata.extendMeta.gainmapColorMeta.alternateColorPrimary = static_cast(hdr) & 0xFF; } static CM_HDR_Metadata_Type GetHdrMediaType(HdrMetadata& metadata) diff --git a/frameworks/innerkitsimpl/utils/src/image_utils.cpp b/frameworks/innerkitsimpl/utils/src/image_utils.cpp index ba67e2ffe..a7f399d4e 100644 --- a/frameworks/innerkitsimpl/utils/src/image_utils.cpp +++ b/frameworks/innerkitsimpl/utils/src/image_utils.cpp @@ -968,9 +968,15 @@ bool ImageUtils::SetInitializationOptionAllocatorType(InitializationOptions &opt uint32_t ImageUtils::SaveDataToFile(const std::string& fileName, const char* data, const size_t& totalSize) { - std::ofstream outFile(fileName, std::ofstream::out); + char realLoadPath[PATH_MAX] = { 0 }; + if (realpath(fileName.c_str(), realLoadPath) == nullptr) { + IMAGE_LOGE("realpath check failed"); + return IMAGE_RESULT_SAVE_DATA_TO_FILE_FAILED; + } + std::string loadPath(realLoadPath); + std::ofstream outFile(loadPath, std::ofstream::out); if (!outFile.is_open()) { - IMAGE_LOGI("ImageUtils::SaveDataToFile write error, path=%{public}s", fileName.c_str()); + IMAGE_LOGI("ImageUtils::SaveDataToFile write error, path=%{public}s", loadPath.c_str()); return IMAGE_RESULT_SAVE_DATA_TO_FILE_FAILED; } if (data == nullptr) { diff --git a/plugins/common/libs/image/libextplugin/src/texture_encode/image_compressor.cpp b/plugins/common/libs/image/libextplugin/src/texture_encode/image_compressor.cpp index d939c9a92..23adbc8a0 100644 --- a/plugins/common/libs/image/libextplugin/src/texture_encode/image_compressor.cpp +++ b/plugins/common/libs/image/libextplugin/src/texture_encode/image_compressor.cpp @@ -1400,9 +1400,14 @@ static CL_ASTC_STATUS SaveClBin(cl_program program, const std::string &clBinPath free(programBinaries); return CL_ASTC_ENC_FAILED; } - FILE *fp = fopen(clBinPath.c_str(), "wb"); + char realLoadPath[PATH_MAX] = { 0 }; + if (realpath(clBinPath.c_str(), realLoadPath) == nullptr) { + IMAGE_LOGE("realpath check failed"); + return CL_ASTC_ENC_FAILED; + } + FILE *fp = fopen(realLoadPath, "wb"); if (fp == nullptr) { - IMAGE_LOGE("astc create file: %{public}s failed!", clBinPath.c_str()); + IMAGE_LOGE("astc create file: %{public}s failed!", realLoadPath); free(programBinaries); return CL_ASTC_ENC_FAILED; } diff --git a/plugins/common/libs/image/libpngplugin/src/png_decoder.cpp b/plugins/common/libs/image/libpngplugin/src/png_decoder.cpp index d9bc65275..8bc16ba64 100644 --- a/plugins/common/libs/image/libpngplugin/src/png_decoder.cpp +++ b/plugins/common/libs/image/libpngplugin/src/png_decoder.cpp @@ -735,6 +735,7 @@ uint32_t PngDecoder::ReadIncrementalHead(InputDataStream *stream, PngImageInfo & } stream->Seek(pos); // set the exception handle + CHECK_ERROR_RETURN_RET_LOG(pngStructPtr_ == nullptr, ERR_IMAGE_DECODE_HEAD_ABNORMAL, "pngStructPtr_ is nullptr"); if (png_jmpbuf(pngStructPtr_) == nullptr) { return ERR_IMAGE_DECODE_HEAD_ABNORMAL; } @@ -928,6 +929,7 @@ uint32_t PngDecoder::IncrementalReadRows(InputDataStream *stream) return ERR_IMAGE_INVALID_PARAMETER; } // set the exception handle + CHECK_ERROR_RETURN_RET_LOG(pngStructPtr_ == nullptr, ERR_IMAGE_DECODE_ABNORMAL, "pngStructPtr_ is nullptr"); if (png_jmpbuf(pngStructPtr_) == nullptr) { return ERR_IMAGE_DECODE_ABNORMAL; } @@ -1074,6 +1076,7 @@ uint32_t PngDecoder::ConfigInfo(const PixelDecodeOptions &opts) } // get the libpng interface exception. + CHECK_ERROR_RETURN_RET_LOG(pngStructPtr_ == nullptr, ERR_IMAGE_DATA_ABNORMAL, "pngStructPtr_ is nullptr"); if (png_jmpbuf(pngStructPtr_) == nullptr) { return ERR_IMAGE_DATA_ABNORMAL; } @@ -1092,6 +1095,7 @@ uint32_t PngDecoder::DoOneTimeDecode(DecodeContext &context) IMAGE_LOGE("normal decode the image source incomplete."); return ERR_IMAGE_SOURCE_DATA_INCOMPLETE; } + CHECK_ERROR_RETURN_RET_LOG(pngStructPtr_ == nullptr, ERR_IMAGE_DECODE_ABNORMAL, "pngStructPtr_ is nullptr"); if (png_jmpbuf(pngStructPtr_) == nullptr) { return ERR_IMAGE_DECODE_ABNORMAL; } diff --git a/plugins/manager/src/common/platform_adp.cpp b/plugins/manager/src/common/platform_adp.cpp index 3f3d0ecc5..ea3cfe715 100644 --- a/plugins/manager/src/common/platform_adp.cpp +++ b/plugins/manager/src/common/platform_adp.cpp @@ -54,7 +54,17 @@ FARPROC PlatformAdp::AdpGetSymAddress(HMODULE handle, const string &symbol) #else void *PlatformAdp::LoadLibrary(const std::string &packageName) { - return dlopen(packageName.c_str(), RTLD_LAZY); + char realLoadPath[PATH_MAX] = { 0 }; + if (realpath(packageName.c_str(), realLoadPath) == nullptr) { + IMAGE_LOGE("realpath check failed"); + return nullptr; + } + struct stat fileStat; + if (stat(realLoadPath, &fileStat) != 0) { + IMAGE_LOGE("unable to get file info"); + return nullptr; + } + return dlopen(realLoadPath, RTLD_LAZY); } void PlatformAdp::FreeLibrary(void *handle) -- Gitee From 3297da7c0a068994c03b2cd1094872836dbe3eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=85=89=E8=80=80?= Date: Thu, 11 Sep 2025 01:59:51 +0000 Subject: [PATCH 2/3] update plugins/manager/src/common/platform_adp.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 何光耀 --- plugins/manager/src/common/platform_adp.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plugins/manager/src/common/platform_adp.cpp b/plugins/manager/src/common/platform_adp.cpp index ea3cfe715..7b8022f98 100644 --- a/plugins/manager/src/common/platform_adp.cpp +++ b/plugins/manager/src/common/platform_adp.cpp @@ -59,11 +59,6 @@ void *PlatformAdp::LoadLibrary(const std::string &packageName) IMAGE_LOGE("realpath check failed"); return nullptr; } - struct stat fileStat; - if (stat(realLoadPath, &fileStat) != 0) { - IMAGE_LOGE("unable to get file info"); - return nullptr; - } return dlopen(realLoadPath, RTLD_LAZY); } -- Gitee From b702218bcd93ad3b9627f1a7961ac1bf13c34959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=85=89=E8=80=80?= Date: Thu, 11 Sep 2025 03:02:31 +0000 Subject: [PATCH 3/3] update plugins/manager/src/common/platform_adp.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 何光耀 --- plugins/manager/src/common/platform_adp.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/manager/src/common/platform_adp.cpp b/plugins/manager/src/common/platform_adp.cpp index 7b8022f98..f3ffd5f45 100644 --- a/plugins/manager/src/common/platform_adp.cpp +++ b/plugins/manager/src/common/platform_adp.cpp @@ -54,12 +54,12 @@ FARPROC PlatformAdp::AdpGetSymAddress(HMODULE handle, const string &symbol) #else void *PlatformAdp::LoadLibrary(const std::string &packageName) { - char realLoadPath[PATH_MAX] = { 0 }; - if (realpath(packageName.c_str(), realLoadPath) == nullptr) { - IMAGE_LOGE("realpath check failed"); + struct stat fileStat; + if (stat(packageName.c_str(), &fileStat) != 0) { + IMAGE_LOGE("unable to get file info"); return nullptr; } - return dlopen(realLoadPath, RTLD_LAZY); + return dlopen(packageName.c_str(), RTLD_LAZY); } void PlatformAdp::FreeLibrary(void *handle) -- Gitee