summaryrefslogtreecommitdiff
path: root/Cryptlib/SysCall/BaseStrings.c
diff options
context:
space:
mode:
authorGary Lin <glin@suse.com>2017-04-07 12:32:24 +0800
committerPeter Jones <pjones@redhat.com>2017-09-08 14:47:09 -0400
commit80a5aa9d1b47d3bbe58bc303513468ff00f60017 (patch)
treefb235b15f2be11585b5c178f08e53643b45e63d0 /Cryptlib/SysCall/BaseStrings.c
parent2fdba73012dea93ad61bba855cb882e4d1d67d48 (diff)
downloadefi-boot-shim-80a5aa9d1b47d3bbe58bc303513468ff00f60017.tar.gz
efi-boot-shim-80a5aa9d1b47d3bbe58bc303513468ff00f60017.zip
Cryptlib: amend the headers and fix signness
- Declare some functions in the proper headers + We missed them for a long time... - Cast offsetof to UINTN + The original casting triggers the gcc warning since int can not present the offset for the 64bit machines. - Cast the "char" array to "CHAR8 *" to avoid the gcc warnings - Implement atoi correctly Signed-off-by: Gary Lin <glin@suse.com>
Diffstat (limited to 'Cryptlib/SysCall/BaseStrings.c')
-rw-r--r--Cryptlib/SysCall/BaseStrings.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/Cryptlib/SysCall/BaseStrings.c b/Cryptlib/SysCall/BaseStrings.c
index 1844a657..252e6db3 100644
--- a/Cryptlib/SysCall/BaseStrings.c
+++ b/Cryptlib/SysCall/BaseStrings.c
@@ -1,9 +1,9 @@
#include <OpenSslSupport.h>
-CHAR8 *
-AsciiStrCat(CHAR8 *Destination, CHAR8 *Source)
+char *
+AsciiStrCat(char *Destination, char *Source)
{
- UINTN dest_len = strlena(Destination);
+ UINTN dest_len = strlena((CHAR8 *)Destination);
UINTN i;
for (i = 0; Source[i] != '\0'; i++)
@@ -25,8 +25,8 @@ AsciiStrCpy(CHAR8 *Destination, CHAR8 *Source)
return Destination;
}
-CHAR8 *
-AsciiStrnCpy(CHAR8 *Destination, CHAR8 *Source, UINTN count)
+char *
+AsciiStrnCpy(char *Destination, char *Source, UINTN count)
{
UINTN i;
@@ -93,3 +93,33 @@ strcasecmp (const char *str1, const char *str2)
return c1 - c2;
}
+
+/* Based on AsciiStrDecimalToUintnS() in edk2
+ * MdePkg/Library/BaseLib/SafeString.c */
+UINTN
+AsciiStrDecimalToUintn(const char *String)
+{
+ UINTN Result;
+
+ if (String == NULL)
+ return 0;
+
+ /* Ignore the pad spaces (space or tab) */
+ while ((*String == ' ') || (*String == '\t')) {
+ String++;
+ }
+
+ /* Ignore leading Zeros after the spaces */
+ while (*String == '0') {
+ String++;
+ }
+
+ Result = 0;
+
+ while (*String >= '0' && *String <= '9') {
+ Result = Result * 10 + (*String - '0');
+ String++;
+ }
+
+ return Result;
+}