]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/SafeString.c
MdePkg: ensure SafeString length functions don't access beyond MaxSize
[mirror_edk2.git] / MdePkg / Library / BaseLib / SafeString.c
index 7c1b0758f3e0fbb5fb8114cb0ee36002679c9e49..b0e1ce72e2986349f85e1ea8cb7af2cb7d6e9d6a 100644 (file)
@@ -141,7 +141,7 @@ StrnLenS (
   // String then StrnLenS returns MaxSize. At most the first MaxSize characters of String shall\r
   // be accessed by StrnLenS.\r
   //\r
-  for (Length = 0; (*String != 0) && (Length < MaxSize); String++, Length++) {\r
+  for (Length = 0; (Length < MaxSize) && (*String != 0); String++, Length++) {\r
     ;\r
   }\r
   return Length;\r
@@ -551,7 +551,7 @@ AsciiStrnLenS (
   // String then AsciiStrnLenS returns MaxSize. At most the first MaxSize characters of String shall\r
   // be accessed by AsciiStrnLenS.\r
   //\r
-  for (Length = 0; (*String != 0) && (Length < MaxSize); String++, Length++) {\r
+  for (Length = 0; (Length < MaxSize) && (*String != 0); String++, Length++) {\r
     ;\r
   }\r
   return Length;\r