]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/String.c
Fix bug in StrnCpy() and AsciStrnCpy(). It was copying Length - 1 characters instead...
[mirror_edk2.git] / MdePkg / Library / BaseLib / String.c
index fb39a22a425203fade7ad03d2770b9a21054d057..86828e65fc2af52d4619c2d261311d2f2e242874 100644 (file)
@@ -116,7 +116,7 @@ StrnCpy (
 \r
   ReturnValue = Destination;\r
 \r
 \r
   ReturnValue = Destination;\r
 \r
-  while ((*Source != L'\0') && (Length > 1)) {\r
+  while ((*Source != L'\0') && (Length > 0)) {\r
     *(Destination++) = *(Source++);\r
     Length--;\r
   }\r
     *(Destination++) = *(Source++);\r
     Length--;\r
   }\r
@@ -481,7 +481,7 @@ AsciiStrnCpy (
 \r
   ReturnValue = Destination;\r
 \r
 \r
   ReturnValue = Destination;\r
 \r
-  while (*Source && Length > 1) {\r
+  while (*Source && Length > 0) {\r
     *(Destination++) = *(Source++);\r
     Length--;\r
   }\r
     *(Destination++) = *(Source++);\r
     Length--;\r
   }\r