Skip to content

Commit

Permalink
Fix length checking in toZenohKeyString()
Browse files Browse the repository at this point in the history
Adds check on micro-serialized URIs for lengths between zero and the
minimum allowable length.
  • Loading branch information
gregmedd authored and stevenhartley committed Apr 9, 2024
1 parent a81dcfe commit 7bfa535
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/src/zenohUri.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ std::string toZenohKeyString(const uprotocol::v1::UUri &u_uri) {
}
} else if (auto uri = Serializer::serialize(u_uri); uri.empty()) {
spdlog::error("Serialized micro URI is empty");
} else if (uri.size() < Serializer::LocalMicroUriLength) {
spdlog::error(
"Serialized micro URI has unexpected length of {} (should be "
"at least {})", uri.size(), Serializer::LocalMicroUriLength);
} else {
if (uri.size() == Serializer::LocalMicroUriLength) {
topic << local_prefix << separator;
Expand Down

0 comments on commit 7bfa535

Please sign in to comment.