mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-11-30 15:53:22 -05:00
s390: fix strrchr() implementation
commit 8e0ab8e26b72a80e991c66a8abc16e6c856abe3d upstream.
Fix two problems found in the strrchr() implementation for s390
architectures: evaluate empty strings (return the string address instead of
NULL, if '\0' is passed as second argument); evaluate the first character
of non-empty strings (the current implementation stops at the second).
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: [email protected]
Reported-by: Heiko Carstens <[email protected]> (incorrect behavior with empty strings)
Signed-off-by: Roberto Sassu <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Heiko Carstens <[email protected]>
Signed-off-by: Vasily Gorbik <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
5959e22e07
commit
98544ca6cb
1 changed files with 7 additions and 8 deletions
|
|
@ -246,14 +246,13 @@ EXPORT_SYMBOL(strcmp);
|
|||
#ifdef __HAVE_ARCH_STRRCHR
|
||||
char *strrchr(const char *s, int c)
|
||||
{
|
||||
size_t len = __strend(s) - s;
|
||||
ssize_t len = __strend(s) - s;
|
||||
|
||||
if (len)
|
||||
do {
|
||||
if (s[len] == (char) c)
|
||||
return (char *) s + len;
|
||||
} while (--len > 0);
|
||||
return NULL;
|
||||
do {
|
||||
if (s[len] == (char)c)
|
||||
return (char *)s + len;
|
||||
} while (--len >= 0);
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL(strrchr);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue