Skip to content

Commit

Permalink
[chip-tool] remove extra blank line in cert print (#25188)
Browse files Browse the repository at this point in the history
* [chip-tool] remove extra blank line in cert print

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Aug 25, 2023
1 parent 1a047d5 commit 1479228
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ const char * ToCertificate(const chip::ByteSpan & source, chip::MutableCharSpan
return destination.data();
}

size_t base64DataLen = BASE64_ENCODED_LEN(source.size()) + 1;
if (base64DataLen + strlen(header) + strlen(footer) > destination.size())
size_t base64DataLen = BASE64_ENCODED_LEN(source.size());
size_t bufferLen = base64DataLen + 1; // add one character for null-terminator
if (bufferLen + strlen(header) + strlen(footer) > destination.size())
{
ChipLogError(DataManagement, "The certificate buffer is too small to hold the base64 encoded certificate");
return destination.data();
}

chip::Platform::ScopedMemoryBuffer<char> str;
str.Alloc(base64DataLen);
str.Alloc(bufferLen);

auto encodedLen = chip::Base64Encode(source.data(), source.size(), str.Get());
str.Get()[encodedLen] = '\0';
Expand Down

0 comments on commit 1479228

Please sign in to comment.