efi-string: Fix strchr() null byte handling

strchr() should be able to search for the terminating null byte,
our implementation doesn't, let's fix that.
This commit is contained in:
Daan De Meyer
2023-02-22 16:55:07 +01:00
parent 921330af40
commit bbef5a9617
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -112,7 +112,7 @@ DEFINE_STRCPY(char16_t, strcpy16);
s++; \
} \
\
return NULL; \
return c ? NULL : (type *) s; \
}
DEFINE_STRCHR(char, strchr8);
+4
View File
@@ -229,6 +229,8 @@ TEST(strchr8) {
assert_se(strchr8(str, 'a') == &str[0]);
assert_se(strchr8(str, 'c') == &str[2]);
assert_se(strchr8(str, 'B') == &str[4]);
assert_se(strchr8(str, 0) == str + strlen8(str));
}
TEST(strchr16) {
@@ -240,6 +242,8 @@ TEST(strchr16) {
assert_se(strchr16(str, 'a') == &str[0]);
assert_se(strchr16(str, 'c') == &str[2]);
assert_se(strchr16(str, 'B') == &str[4]);
assert_se(strchr16(str, 0) == str + strlen16(str));
}
TEST(xstrndup8) {