]> git.proxmox.com Git - mirror_edk2.git/commitdiff
EmbeddedPkg/MmcDxe: eliminate deprecated string function calls
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Mon, 24 Oct 2016 17:33:31 +0000 (18:33 +0100)
committerArd Biesheuvel <ard.biesheuvel@linaro.org>
Fri, 28 Oct 2016 14:54:00 +0000 (15:54 +0100)
Get rid of calls to unsafe string functions. These are deprecated and may
be removed in the future.

Note that this also fixes an existing issue in the code, where the buffer
may be overrun by one character when en == mLogRemainChar, in which case
the NUL terminator ends up after the end of the buffer.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
EmbeddedPkg/Universal/MmcDxe/Diagnostics.c

index 783e548d2aed6afec644b813ffcf7485dc5d982b..7d6a5a0dde01cf890a86773d3fbafb198f5508ff 100644 (file)
@@ -42,9 +42,9 @@ DiagnosticLog (
   )\r
 {\r
   UINTN len = StrLen (Str);\r
   )\r
 {\r
   UINTN len = StrLen (Str);\r
-  if (len <= mLogRemainChar) {\r
+  if (len < mLogRemainChar) {\r
+    StrCpyS (mLogBuffer, mLogRemainChar, Str);\r
     mLogRemainChar -= len;\r
     mLogRemainChar -= len;\r
-    StrCpy (mLogBuffer, Str);\r
     mLogBuffer += len;\r
     return len;\r
   } else {\r
     mLogBuffer += len;\r
     return len;\r
   } else {\r