summaryrefslogtreecommitdiff
path: root/Cryptlib/SysCall/BaseStrings.c
diff options
context:
space:
mode:
authorGary Lin <glin@suse.com>2017-04-07 17:14:09 +0800
committerPeter Jones <pjones@redhat.com>2017-04-11 10:42:19 -0400
commit9bc647e2b23bcfd69a0077c0717fbc454c919a57 (patch)
treeda0d905c89be95f2ff2de253aa256c7267e7fc70 /Cryptlib/SysCall/BaseStrings.c
parentae75df6232ad30f3e8736e9449692d58a7439260 (diff)
downloadefi-boot-shim-9bc647e2b23bcfd69a0077c0717fbc454c919a57.tar.gz
efi-boot-shim-9bc647e2b23bcfd69a0077c0717fbc454c919a57.zip
Cryptlib: implement strcmp() and strcasecmp()
strcmp() and strcasecmp() are widely used in openssl. Implement those two functions to eliminate the gcc warnings and the potential crash. Signed-off-by: Gary Lin <glin@suse.com>
Diffstat (limited to 'Cryptlib/SysCall/BaseStrings.c')
-rw-r--r--Cryptlib/SysCall/BaseStrings.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/Cryptlib/SysCall/BaseStrings.c b/Cryptlib/SysCall/BaseStrings.c
index 990037d1..2267d862 100644
--- a/Cryptlib/SysCall/BaseStrings.c
+++ b/Cryptlib/SysCall/BaseStrings.c
@@ -93,3 +93,33 @@ AsciiStrDecimalToUintn(const char *String)
return Result;
}
+
+int
+strcmp (const char *str1, const char *str2)
+{
+ return strcmpa((CHAR8 *)str1,(CHAR8 *)str2);
+}
+
+inline static char
+toupper (char c)
+{
+ return ((c >= 'a' && c <= 'z') ? c - ('a' - 'A') : c);
+}
+
+/* Based on AsciiStriCmp() in edk2 MdePkg/Library/BaseLib/String.c */
+int
+strcasecmp (const char *str1, const char *str2)
+{
+ char c1, c2;
+
+ c1 = toupper (*str1);
+ c2 = toupper (*str2);
+ while ((*str1 != '\0') && (c1 == c2)) {
+ str1++;
+ str2++;
+ c1 = toupper (*str1);
+ c2 = toupper (*str2);
+ }
+
+ return c1 - c2;
+}