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-08-31 15:14:20 -0400
commite06765ae0dbbc874ff9e04dbd0e7d82989048261 (patch)
treeab0159ba445235664c190b5a5190f882c0fce0b6 /Cryptlib/SysCall/BaseStrings.c
parent1b5dbc4b4df297e4a351ed2b8434a9021c4041d1 (diff)
downloadefi-boot-shim-e06765ae0dbbc874ff9e04dbd0e7d82989048261.tar.gz
efi-boot-shim-e06765ae0dbbc874ff9e04dbd0e7d82989048261.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.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/Cryptlib/SysCall/BaseStrings.c b/Cryptlib/SysCall/BaseStrings.c
index 43875712..1844a657 100644
--- a/Cryptlib/SysCall/BaseStrings.c
+++ b/Cryptlib/SysCall/BaseStrings.c
@@ -64,4 +64,32 @@ AsciiStrSize(CHAR8 *string)
return strlena(string) + 1;
}
+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;
+}