i2c-vr: fix xdpe1x2xx bugs

1.Due to the lack of a null character, debug messages become abnormal
during file parsing.

2.When performing “Reset the configuration”,
writing more memory than the length declared by data[MaxSectDataCnt] may
cause the program to exit abnormally.

issue log:
```
<7> parsing package header
<7> parsing package, pkg header size: 178
<7> Yosemite5_MB_VR_CPU0_1794: set version 1009
09Z 0x140B21B9/XV0 Config
0000000sing: //XV0 PMBus LoopA User
643C5088ing: //XV0 PMBus LoopB User
07> Parsing: //XV0 FW SVI3 LoopA
07> Parsing: //XV0 FW SVI3 LoopB
00000000ing: [End Configuration Data]
<7> Scratchpad Address: 0x2005f000
<7> CRC before programming: 0x140b21b9
<7> CRC of configuration: 0x140b21b9
```

```
<6> Successfully updated VR Yosemite5_MB_VR_CPU0
corrupted size vs. prev_size
Aborted (core dumped)
root@bmc:~#

<7> Yosemite5_MB_VR_CPU0_1794: creating 'activating' association to /xyz/openbmc_project/inventory/system/board/Yosemite5_MB
free(): invalid pointer
Aborted (core dumped)
root@bmc:~#
```

Change-Id: I7cba7cc5373612d79da641b2e764fa4985377e8b
Signed-off-by: Leo Yang <Leo-Yang@quantatw.com>
diff --git a/i2c-vr/xdpe1x2xx/xdpe1x2xx.cpp b/i2c-vr/xdpe1x2xx/xdpe1x2xx.cpp
index a2d919b..184c17b 100644
--- a/i2c-vr/xdpe1x2xx/xdpe1x2xx.cpp
+++ b/i2c-vr/xdpe1x2xx/xdpe1x2xx.cpp
@@ -481,7 +481,15 @@
     {
         if (image[i] == '\n')
         {
-            std::memcpy(line, image + start, i - start);
+            const size_t lineLength = i - start;
+            if (lineLength >= maxLineLength)
+            {
+                error("line length exceeded 40, please check image file.");
+                return false;
+            }
+            std::memcpy(line, image + start, lineLength);
+            line[lineLength] = '\0';
+
             if (!strncmp(line, DataComment, lenComment))
             {
                 token = line + lenComment;
@@ -705,7 +713,7 @@
     {
         configuration.section[i].type = 0;
         configuration.section[i].dataCnt = 0;
-        for (int j = 0; j <= MaxSectDataCnt; j++)
+        for (int j = 0; j < MaxSectDataCnt; j++)
         {
             configuration.section[i].data[j] = 0;
         }