bugfix: tools: copy string out, expected nul-termination
tools: There were some subtle issues with std::string, where it's not
always nul-terminated. Therefore comparisons that looked identical
weren't because one instance of the std::string would be nul-terminated
and the other not.
test: response from enumerate must nul-terminate bytes
The response from the IPMI command will include a trailing
nul-terminator.
Change-Id: I8ff18b0c52c5288170257414572bee2366ccc431
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/tools/blob_handler.cpp b/tools/blob_handler.cpp
index 75d3cff..a181559 100644
--- a/tools/blob_handler.cpp
+++ b/tools/blob_handler.cpp
@@ -128,9 +128,8 @@
std::copy(data, data + sizeof(std::uint32_t), std::back_inserter(payload));
auto resp = sendIpmiPayload(BlobOEMCommands::bmcBlobEnumerate, payload);
- std::string output;
- std::copy(resp.begin(), resp.end(), std::back_inserter(output));
- return output;
+ return (resp.size() > 0) ? std::string(&resp[0], &resp[resp.size() - 1])
+ : "";
}
std::vector<std::string> BlobHandler::getBlobList()