vfs: check userland buffers before reading them.
[haiku.git] / src / system / libroot / posix / string / strstr.c
blob3f8c9e532f1292dffee411a94b06da65dc3a9261
1 /*
2 * Taken from Wikipedia, which declared it as "public domain".
3 */
5 #include <sys/types.h>
6 #include <string.h>
9 char *
10 strstr(const char *s1, const char *s2)
12 size_t s2len;
13 /* Check for the null s2 case. */
14 if (*s2 == '\0')
15 return (char *) s1;
16 s2len = strlen(s2);
17 for (; (s1 = strchr(s1, *s2)) != NULL; s1++) {
18 if (strncmp(s1, s2, s2len) == 0)
19 return (char *)s1;
21 return NULL;