Fix rstrip on Fru read

Some fru devices initialize strings to end with multiple 0x00.  On dbus,
we want to rstrip those things.

Tested By:
Installed SSD.  Observed correct names on DBUs without trailing slashes.

Observed all other FRU devices acted correctly.

Change-Id: I649b6bc2d2f3dff733f5eae0839bcd7c4cf992c1
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
diff --git a/src/FruDevice.cpp b/src/FruDevice.cpp
index eb56c6a..a5e5c80 100644
--- a/src/FruDevice.cpp
+++ b/src/FruDevice.cpp
@@ -414,31 +414,30 @@
                     return false;
                 }
 
-                size_t length = *fruBytesIter & 0x3f;
-                fruBytesIter += 1;
-
-                /* Checking for length if field present */
-                if (length == 0)
-                {
-                    result[std::string(area) + "_" + field] =
-                        std::string("Null");
-                    continue;
-                }
-
                 /* Checking for last byte C1 to indicate that no more
                  * field to be read */
-                if (length == 1)
+                if (*fruBytesIter == 0xC1)
                 {
                     break;
                 }
 
+                size_t length = *fruBytesIter & 0x3f;
+                fruBytesIter += 1;
+
                 if (fruBytesIter >= fruBytes.end())
                 {
                     return false;
                 }
+                std::string value(fruBytesIter, fruBytesIter + length);
 
-                result[std::string(area) + "_" + field] =
-                    std::string(fruBytesIter, fruBytesIter + length);
+                // Strip non null characters from the end
+                value.erase(std::find_if(value.rbegin(), value.rend(),
+                                         [](char ch) { return ch != 0; })
+                                .base(),
+                            value.end());
+
+                result[std::string(area) + "_" + field] = std::move(value);
+
                 fruBytesIter += length;
                 if (fruBytesIter >= fruBytes.end())
                 {