From 14073827d0abac6a1e21af8796da18dcf53a267b Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Thu, 12 Jan 2023 15:06:16 +0100 Subject: [PATCH] [Tizen] Do not log binary buffer with `%s` (#24380) Printing binary buffer with `%s` might lead to Tizen logger corruption, so no more logs will be readable after such accident. Use dedicated byte span logger for logging preferences data. --- src/platform/Tizen/AppPreference.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/platform/Tizen/AppPreference.cpp b/src/platform/Tizen/AppPreference.cpp index bc6e8f1097ec35..01c4a2b982eae1 100644 --- a/src/platform/Tizen/AppPreference.cpp +++ b/src/platform/Tizen/AppPreference.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace chip { @@ -85,7 +86,9 @@ CHIP_ERROR GetData(const char * key, void * data, size_t dataSize, size_t * getD } ::memcpy(data, decodedData.Get() + offset, copySize); - ChipLogProgress(DeviceLayer, "Get data [%s:%.*s]", key, static_cast(copySize), static_cast(data)); + ChipLogDetail(DeviceLayer, "Get data [%s]: %u", key, static_cast(copySize)); + ChipLogByteSpan(DeviceLayer, ByteSpan(reinterpret_cast(data), copySize)); + return CHIP_NO_ERROR; } @@ -111,7 +114,9 @@ CHIP_ERROR SaveData(const char * key, const void * data, size_t dataSize) return CHIP_ERROR_INCORRECT_STATE; } - ChipLogProgress(DeviceLayer, "Save data [%s:%.*s]", key, static_cast(dataSize), static_cast(data)); + ChipLogDetail(DeviceLayer, "Save data [%s]: %u", key, static_cast(dataSize)); + ChipLogByteSpan(DeviceLayer, ByteSpan(reinterpret_cast(data), dataSize)); + return CHIP_NO_ERROR; }