bugfix: tools: blob_handler: properly handle smallest reply

The smallest reply doesn't include a CRC.

Change-Id: I3c2004b494f7a851d94805d56eb4e7d2c627083e
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/tools/blob_handler.cpp b/tools/blob_handler.cpp
index 06d11e5..572d5c8 100644
--- a/tools/blob_handler.cpp
+++ b/tools/blob_handler.cpp
@@ -35,7 +35,7 @@
     BlobHandler::sendIpmiPayload(BlobOEMCommands command,
                                  const std::vector<std::uint8_t>& payload)
 {
-    std::vector<std::uint8_t> request, reply;
+    std::vector<std::uint8_t> request, reply, bytes;
 
     std::copy(ipmiPhosphorOen.begin(), ipmiPhosphorOen.end(),
               std::back_inserter(request));
@@ -73,12 +73,10 @@
         return reply;
     }
 
-    std::size_t headerSize = ipmiPhosphorOen.size() + sizeof(std::uint16_t);
-
     /* This cannot be a response because it's smaller than the smallest
      * response.
      */
-    if (reply.size() < headerSize)
+    if (reply.size() < ipmiPhosphorOen.size())
     {
         throw BlobException("Invalid response length");
     }
@@ -90,6 +88,13 @@
         throw BlobException("Invalid OEN received");
     }
 
+    /* In this case there was no data, as there was no CRC. */
+    std::size_t headerSize = ipmiPhosphorOen.size() + sizeof(std::uint16_t);
+    if (reply.size() < headerSize)
+    {
+        return {};
+    }
+
     /* Validate CRC. */
     std::uint16_t crc;
     auto ptr = reinterpret_cast<std::uint8_t*>(&crc);
@@ -101,7 +106,6 @@
     }
     std::fprintf(stderr, "\n");
 
-    std::vector<std::uint8_t> bytes;
     bytes.insert(bytes.begin(), reply.begin() + headerSize, reply.end());
 
     auto computed = generateCrc(bytes);