writefrudata: remove vla

Variable length arrays are not allowed in standard C++.  Remove them
in favor of std::vector.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Id6e4d6f287bf59bdb5888b1a2d34e41d72572548
diff --git a/writefrudata.cpp b/writefrudata.cpp
index 1394b38..116f168 100644
--- a/writefrudata.cpp
+++ b/writefrudata.cpp
@@ -11,6 +11,7 @@
 #include <sdbusplus/bus.hpp>
 
 #include <algorithm>
+#include <array>
 #include <cstdio>
 #include <cstring>
 #include <exception>
@@ -18,6 +19,7 @@
 #include <iostream>
 #include <map>
 #include <memory>
+#include <span>
 #include <sstream>
 #include <vector>
 
@@ -524,8 +526,6 @@
                 areaLen = areaHeader[1] * IPMI_EIGHT_BYTES;
             }
 
-            uint8_t areaData[areaLen] = {0};
-
             log<level::DEBUG>("FRU Data", entry("SIZE=%d", dataLen),
                               entry("AREA OFFSET=%d", areaOffset),
                               entry("AREA_SIZE=%d", areaLen));
@@ -539,8 +539,10 @@
                 return rc;
             }
 
-            // Save off the data.
-            std::memcpy(areaData, &((uint8_t*)fruData)[areaOffset], areaLen);
+            auto fruDataView = std::span<uint8_t>(&fruData[areaOffset],
+                                                  areaLen);
+            auto areaData = std::vector<uint8_t>(fruDataView.begin(),
+                                                 fruDataView.end());
 
             // Validate the CRC, but not for the internal use area, since its
             // contents beyond the first byte are not defined in the spec and
@@ -549,11 +551,12 @@
 
             if (fruEntry == IPMI_FRU_MULTI_OFFSET)
             {
-                rc = verifyFruMultiRecData(areaData, areaLen, validateCrc);
+                rc = verifyFruMultiRecData(areaData.data(), areaLen,
+                                           validateCrc);
             }
             else
             {
-                rc = verifyFruData(areaData, areaLen, validateCrc);
+                rc = verifyFruData(areaData.data(), areaLen, validateCrc);
             }
 
             if (rc < 0)
@@ -574,7 +577,7 @@
             {
                 if (iter->getType() == getFruAreaType(fruEntry))
                 {
-                    iter->setData(areaData, areaLen);
+                    iter->setData(areaData.data(), areaLen);
                 }
             }
         } // If we have FRU data present
@@ -668,10 +671,11 @@
 
     // Allocate a buffer to hold entire file content
     dataLen = std::ftell(fruFilePointer);
-    uint8_t fruData[dataLen] = {0};
+
+    auto fruData = std::vector<uint8_t>(dataLen, 0);
 
     std::rewind(fruFilePointer);
-    bytesRead = std::fread(fruData, dataLen, 1, fruFilePointer);
+    bytesRead = std::fread(fruData.data(), dataLen, 1, fruFilePointer);
     if (bytesRead != 1)
     {
         log<level::ERR>("Failed reading FRU data.",
@@ -684,7 +688,7 @@
     std::fclose(fruFilePointer);
     fruFilePointer = NULL;
 
-    rc = ipmiValidateCommonHeader(fruData, dataLen);
+    rc = ipmiValidateCommonHeader(fruData.data(), dataLen);
     if (rc < 0)
     {
         return cleanupError(fruFilePointer, fruAreaVec);
@@ -692,7 +696,7 @@
 
     // Now that we validated the common header, populate various FRU sections if
     // we have them here.
-    rc = ipmiPopulateFruAreas(fruData, dataLen, fruAreaVec);
+    rc = ipmiPopulateFruAreas(fruData.data(), dataLen, fruAreaVec);
     if (rc < 0)
     {
         log<level::ERR>("Populating FRU areas failed", entry("FRU=%d", fruid));