Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
NetDb: remove unnecessary null terminators
Browse files Browse the repository at this point in the history
  • Loading branch information
anonimal committed May 19, 2017
1 parent ce2ddbc commit 1d8d8cd
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/core/router/net_db/impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,7 @@ void NetDb::HandleDatabaseSearchReplyMsg(
std::shared_ptr<const I2NPMessage> msg) {
const std::uint8_t* buf = msg->GetPayload();
std::array<char, 48> key;
std::uint8_t len = core::ByteStreamToBase64(buf, 32, key.data(), key.size());
key.at(len) = 0; // TODO(anonimal): remove
core::ByteStreamToBase64(buf, 32, key.data(), key.size());
std::uint8_t num = buf[32]; // num
LOG(debug) << "NetDb: DatabaseSearchReply for " << key.data() << " num=" << num;
IdentHash ident(buf);
Expand Down Expand Up @@ -643,8 +642,7 @@ void NetDb::HandleDatabaseSearchReplyMsg(
for (std::uint8_t i = 0; i < num; i++) {
const std::uint8_t* router = buf + 33 + i * 32;
std::array<char, 48> peer_hash;
std::uint8_t len = kovri::core::ByteStreamToBase64(router, 32, peer_hash.data(), peer_hash.size());
peer_hash.at(len) = 0; // TODO(anonimal): remove
core::ByteStreamToBase64(router, 32, peer_hash.data(), peer_hash.size());
LOG(debug) << "NetDb: " << i << ": " << peer_hash.data();
auto r = FindRouter(router);
if (!r || kovri::core::GetMillisecondsSinceEpoch() >
Expand All @@ -667,8 +665,7 @@ void NetDb::HandleDatabaseLookupMsg(
return;
}
std::array<char, 48> key;
std::uint8_t len = kovri::core::ByteStreamToBase64(buf, 32, key.data(), key.size());
key.at(len) = 0; // TODO(anonimal): remove
core::ByteStreamToBase64(buf, 32, key.data(), key.size());
std::uint8_t flag = buf[64];
LOG(debug)
<< "NetDb: DatabaseLookup for " << key.data()
Expand Down

0 comments on commit 1d8d8cd

Please sign in to comment.