Align writing to the VGA memory at page boundary

Change-Id: If832facfdbffb7acfb9834ea70664678aa6e8376
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/libpldmresponder/file_io.cpp b/libpldmresponder/file_io.cpp
index a6c9fae..a513f59 100644
--- a/libpldmresponder/file_io.cpp
+++ b/libpldmresponder/file_io.cpp
@@ -87,9 +87,16 @@
     if (upstream)
     {
         std::ifstream stream(path.string());
-
         stream.seekg(offset);
-        stream.read(static_cast<char*>(vgaMemPtr.get()), length);
+
+        // Writing to the VGA memory should be aligned at page boundary,
+        // otherwise write data into a buffer aligned at page boundary and
+        // then write to the VGA memory.
+        std::vector<char> buffer{};
+        buffer.resize(pageAlignedLength);
+        stream.read(buffer.data(), length);
+        memcpy(static_cast<char*>(vgaMemPtr.get()), buffer.data(),
+               pageAlignedLength);
 
         if (static_cast<uint32_t>(stream.gcount()) != length)
         {