summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-03-10 14:26:46 -0500
committerPeter Jones <pjones@redhat.com>2021-03-10 15:54:20 -0500
commitc722a590d08506f29ddb70c1c57c511a836efb7a (patch)
tree8e72ee8b1faf0eda742210ab174ac9318772662d /lib
parent8d006f5c70b19d6e7f35f83e61880deb45b05977 (diff)
downloadefi-boot-shim-c722a590d08506f29ddb70c1c57c511a836efb7a.tar.gz
efi-boot-shim-c722a590d08506f29ddb70c1c57c511a836efb7a.zip
Add more string test cases.
This adds test cases for the rest of our ASCII string functions. While doing so, it fixes two minor bugs: - strcasecmp() now handles utf8 correctly - strncpy() no longer does the stpncpy() behavior of clearing leftover buffer Signed-off-by: Peter Jones <pjones@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/string.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/string.c b/lib/string.c
index 3dc6f1cd..37eabe8c 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -13,6 +13,7 @@
#define strcasecmp shim_strcasecmp
#define strrchr shim_strrchr
#define strlen shim_strlen
+#define strnlen shim_strnlen
#define strcpy shim_strcpy
#define strncpy shim_strncpy
#define strdup shim_strdup
@@ -93,7 +94,7 @@ strncasecmp(const char *s1p, const char *s2p, size_t n)
int
strcasecmp(const char *str1, const char *str2)
{
- char c1, c2;
+ uint8_t c1, c2;
c1 = toupper(*str1);
c2 = toupper(*str2);
@@ -155,7 +156,7 @@ strncpy(char *dest, const char *src, size_t n)
for (i = 0; i < n && src[i] != '\0'; i++)
dest[i] = src[i];
- for (; i < n; i++)
+ if (i < n)
dest[i] = '\0';
return dest;