strcasestr: check if ne[0] is in hs with strchr or strpbrk as does strstr
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
redhat-pt-bot/TryBot-32bit |
success
|
Build for i686
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Testing passed
|
Commit Message
---
string/strcasestr.c | 8 ++++++++
1 file changed, 8 insertions(+)
@@ -67,6 +67,14 @@ STRCASESTR (const char *haystack, const char *needle)
/* Handle empty NEEDLE special case. */
if (needle[0] == '\0')
return (char *) haystack;
+ if (isalpha(*needle)) {
+ const char a[] = { tolower(*needle), toupper(*needle), '\0'};
+ haystack = strpbrk(haystack, a);
+ } else {
+ haystack = strchr(haystack, *needle);
+ }
+ if (haystack == NULL || needle[1] == '\0')
+ return (char *)haystack;
/* Ensure HAYSTACK length is at least as long as NEEDLE length.
Since a match may occur early on in a huge HAYSTACK, use strnlen