Skip to content

Commit

Permalink
[Tizen] Do not log binary buffer with %s (#24380)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
arkq authored Jan 12, 2023
1 parent 9beb397 commit 361f324
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/platform/Tizen/AppPreference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <lib/support/Base64.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/ScopedBuffer.h>
#include <lib/support/Span.h>
#include <lib/support/logging/CHIPLogging.h>

namespace chip {
Expand Down Expand Up @@ -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<int>(copySize), static_cast<char *>(data));
ChipLogDetail(DeviceLayer, "Get data [%s]: %u", key, static_cast<unsigned int>(copySize));
ChipLogByteSpan(DeviceLayer, ByteSpan(reinterpret_cast<uint8_t *>(data), copySize));

return CHIP_NO_ERROR;
}

Expand All @@ -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<int>(dataSize), static_cast<const char *>(data));
ChipLogDetail(DeviceLayer, "Save data [%s]: %u", key, static_cast<unsigned int>(dataSize));
ChipLogByteSpan(DeviceLayer, ByteSpan(reinterpret_cast<const uint8_t *>(data), dataSize));

return CHIP_NO_ERROR;
}

Expand Down

0 comments on commit 361f324

Please sign in to comment.