Fix strstr() indent and rewrite to not call strlen() on each char
Coverity #75583 flagged an indentation error in strstr().
While looking at that, I noticed that strstr() is calling strlen() for
each character it compares. That led me to look closer.
And I found that the function was badly broken.
Examples of bad results:
strstr("foobar", "foo") => 1
strstr("foobar", "ob") => -1
So I rewrote strlen() using memcmp().
I also made the parameters "const" and cleaned up strlen().
Signed-off-by: Ben Gardner <firstname.lastname@example.org>
Tested-by: build bot (Jenkins)
Reviewed-by: Martin Roth <email@example.com>
2 files changed