diff options
author | Laszlo Ersek <lersek@redhat.com> | 2016-10-21 21:31:09 +0200 |
---|---|---|
committer | Laszlo Ersek <lersek@redhat.com> | 2016-10-25 10:46:42 +0200 |
commit | a1848bc088c62ae5a19e20e95c22d7b4fb75d2cb (patch) | |
tree | 1f1ab5b4ba1fac594a68ffbdd1dbae15e81984ed /ArmPkg/Library | |
parent | f00ace96f3c8e1dbfd0cd0d882b0c98cfbde37dc (diff) | |
download | edk2-platforms-a1848bc088c62ae5a19e20e95c22d7b4fb75d2cb.tar.xz |
ArmPkg/DefaultExceptionHandlerLib: replace AsciiStrCat() with AsciiStrCatS()
AsciiStrCat() is deprecated / disabled under the
DISABLE_NEW_DEPRECATED_INTERFACES feature test macro.
The caller of CpsrString() is required to pass in "ReturnStr" with 32
CHAR8 elements. (DefaultExceptionHandler() complies with this.) "Str" is
used to build "ReturnStr" gradually. Just before calling AsciiStrCat(),
"Str" points to the then-terminating NUL character in "ReturnStr".
The difference (Str - ReturnStr) gives the number of non-NUL characters
we've written thus far, hence (32 - (Str - ReturnStr)) yields the number
of remaining bytes in ReturnStr, including the ultimately terminating NUL
character.
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Michael Zimmermann <sigmaepsilon92@gmail.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=164
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=165
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Diffstat (limited to 'ArmPkg/Library')
-rw-r--r-- | ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c index aece26355e..0b9da031b4 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c @@ -27,6 +27,12 @@ #include <Protocol/DebugSupport.h>
#include <Library/DefaultExceptionHandlerLib.h>
+//
+// The number of elements in a CHAR8 array, including the terminating NUL, that
+// is meant to hold the string rendering of the CPSR.
+//
+#define CPSR_STRING_SIZE 32
+
typedef struct {
UINT32 BIT;
CHAR8 Char;
@@ -46,7 +52,8 @@ GetImageName ( It is possible to add extra bits by adding them to CpsrChar array.
@param Cpsr ARM CPSR register value
- @param ReturnStr 32 byte string that contains string version of CPSR
+ @param ReturnStr CPSR_STRING_SIZE byte string that contains string
+ version of CPSR
**/
VOID
@@ -116,8 +123,10 @@ CpsrString ( break;
}
- AsciiStrCat (Str, ModeStr);
- return;
+ //
+ // See the interface contract in the leading comment block.
+ //
+ AsciiStrCatS (Str, CPSR_STRING_SIZE - (Str - ReturnStr), ModeStr);
}
CHAR8 *
@@ -192,7 +201,8 @@ DefaultExceptionHandler ( UINT32 ImageBase;
UINT32 PeCoffSizeOfHeader;
UINT32 Offset;
- CHAR8 CpsrStr[32]; // char per bit. Lower 5-bits are mode that is a 3 char string
+ CHAR8 CpsrStr[CPSR_STRING_SIZE]; // char per bit. Lower 5-bits are mode
+ // that is a 3 char string
CHAR8 Buffer[80];
UINT8 *DisAsm;
UINT32 ItBlock;
|