Merge remote-tracking branch 'gfiber-internal/master' into merger

* gfiber-internal/master:
  HMX_NVRAM_SetField fix: check actual field size for skipping check.
diff --git a/libupgrade/hmx_upgrade_nvram.c b/libupgrade/hmx_upgrade_nvram.c
index ecd198e..eb3ca59 100644
--- a/libupgrade/hmx_upgrade_nvram.c
+++ b/libupgrade/hmx_upgrade_nvram.c
@@ -871,9 +871,14 @@
     return DRV_ERR_OUTOFMEMORY;
   }
 
-  errCode = HMX_NVRAM_GetFieldAndSize(field, offset, pBuf, nDataSize, &pLen);
-  if (errCode == DRV_OK) {
-    if (memcmp(pBuf, data, nDataSize) == 0 && pLen == nDataSize) {
+  int fieldLen = 0;
+  // Need to use fieldLen for actual field length because pLen is always
+  // <= nDataSize. If input data size is shorter this may falsely skip hnvram
+  // writing.
+  if (HMX_NVRAM_GetLength(field, &fieldLen) == DRV_OK &&
+      HMX_NVRAM_GetFieldAndSize(field, offset, pBuf, nDataSize, &pLen)
+      == DRV_OK) {
+    if (memcmp(pBuf, data, nDataSize) == 0 && fieldLen == nDataSize) {
       free(pBuf);
       return DRV_OK;
     }