public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ArmPkg: remove usages of deprecated API's
@ 2016-08-08  5:44 Michael Zimmermann
  0 siblings, 0 replies; only message in thread
From: Michael Zimmermann @ 2016-08-08  5:44 UTC (permalink / raw)
  To: edk2-devel-01, Leif Lindholm, Ard Biesheuvel

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Zimmermann <sigmaepsilon92@gmail.com>
---
 ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c | 21
+++++++++++----------
 .../Library/ArmDisassemblerLib/ThumbDisassembler.c  | 19
++++++++++---------
 .../Arm/DefaultExceptionHandler.c                   |  9 ++++++---
 3 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
index 29a8d44..410078f 100644
--- a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
+++ b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
@@ -80,7 +80,8 @@ CHAR8 *gLdmStack[] = {
 #define BYTE(_B)  ((_B) ? "B":"")
 #define USER(_B)  ((_B) ? "^" : "")

-CHAR8 mMregListStr[4*15 + 1];
+#define REGLISTSTR_SIZE (4*15 + 1)
+CHAR8 mMregListStr[REGLISTSTR_SIZE];

 CHAR8 *
 MRegList (
@@ -93,7 +94,7 @@ MRegList (

   Str = mMregListStr;
   *Str = '\0';
-  AsciiStrCat  (Str, "{");
+  AsciiStrCatS  (Str, REGLISTSTR_SIZE, "{");
   for (Index = 0, First = TRUE; Index <= 15; Index++) {
     if ((OpCode & (1 << Index)) != 0) {
       Start = End = Index;
@@ -102,25 +103,25 @@ MRegList (
       }

       if (!First) {
-        AsciiStrCat  (Str, ",");
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, ",");
       } else {
         First = FALSE;
       }

       if (Start == End) {
-        AsciiStrCat  (Str, gReg[Start]);
-        AsciiStrCat  (Str, ", ");
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, gReg[Start]);
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, ", ");
       } else {
-        AsciiStrCat  (Str, gReg[Start]);
-        AsciiStrCat  (Str, "-");
-        AsciiStrCat  (Str, gReg[End]);
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, gReg[Start]);
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, "-");
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, gReg[End]);
       }
     }
   }
   if (First) {
-    AsciiStrCat  (Str, "ERROR");
+    AsciiStrCatS  (Str, REGLISTSTR_SIZE, "ERROR");
   }
-  AsciiStrCat  (Str, "}");
+  AsciiStrCatS  (Str, REGLISTSTR_SIZE, "}");

   // BugBug: Make caller pass in buffer it is cleaner
   return mMregListStr;
diff --git a/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c
b/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c
index 5bad3af..4f3af9a 100644
--- a/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c
+++ b/ArmPkg/Library/ArmDisassemblerLib/ThumbDisassembler.c
@@ -389,7 +389,8 @@ CHAR8 *gShiftType[] = {
   "ROR"
 };

-CHAR8 mThumbMregListStr[4*15 + 1];
+#define REGLISTSTR_SIZE (4*15 + 1)
+CHAR8 mThumbMregListStr[REGLISTSTR_SIZE];

 CHAR8 *
 ThumbMRegList (
@@ -402,7 +403,7 @@ ThumbMRegList (

   Str = mThumbMregListStr;
   *Str = '\0';
-  AsciiStrCat  (Str, "{");
+  AsciiStrCatS  (Str, REGLISTSTR_SIZE, "{");

   for (Index = 0, First = TRUE; Index <= 15; Index++) {
     if ((RegBitMask & (1 << Index)) != 0) {
@@ -412,24 +413,24 @@ ThumbMRegList (
       }

       if (!First) {
-        AsciiStrCat  (Str, ",");
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, ",");
       } else {
         First = FALSE;
       }

       if (Start == End) {
-        AsciiStrCat  (Str, gReg[Start]);
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, gReg[Start]);
       } else {
-        AsciiStrCat  (Str, gReg[Start]);
-        AsciiStrCat  (Str, "-");
-        AsciiStrCat  (Str, gReg[End]);
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, gReg[Start]);
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, "-");
+        AsciiStrCatS  (Str, REGLISTSTR_SIZE, gReg[End]);
       }
     }
   }
   if (First) {
-    AsciiStrCat  (Str, "ERROR");
+    AsciiStrCatS  (Str, REGLISTSTR_SIZE, "ERROR");
   }
-  AsciiStrCat  (Str, "}");
+  AsciiStrCatS  (Str, REGLISTSTR_SIZE, "}");

   // BugBug: Make caller pass in buffer it is cleaner
   return mThumbMregListStr;
diff --git
a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
index aece263..fe4abb6 100644
---
a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
+++
b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c
@@ -47,12 +47,14 @@ GetImageName (

   @param  Cpsr         ARM CPSR register value
   @param  ReturnStr    32 byte string that contains string version of CPSR
+  @param  ReturnSize   The size of ReturnSize including the terminating
null char.

 **/
 VOID
 CpsrString (
   IN  UINT32  Cpsr,
-  OUT CHAR8   *ReturnStr
+  OUT CHAR8   *ReturnStr,
+  IN  UINTN   ReturnSize
   )
 {
   UINTN     Index;
@@ -84,6 +86,7 @@ CpsrString (

   *Str++ = '_';
   *Str = '\0';
+  ReturnSize--;

   switch (Cpsr & 0x1f) {
   case 0x10:
@@ -116,7 +119,7 @@ CpsrString (
     break;
   }

-  AsciiStrCat (Str, ModeStr);
+  AsciiStrCatS (Str, ReturnSize, ModeStr);
   return;
 }

@@ -197,7 +200,7 @@ DefaultExceptionHandler (
     UINT8   *DisAsm;
     UINT32  ItBlock;

-    CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr);
+    CpsrString (SystemContext.SystemContextArm->CPSR, CpsrStr,
sizeof(CpsrStr));
     DEBUG ((EFI_D_ERROR, "%a\n", CpsrStr));

     Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase,
&PeCoffSizeOfHeader);
-- 
2.9.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-08  5:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-08  5:44 [PATCH] ArmPkg: remove usages of deprecated API's Michael Zimmermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox