summaryrefslogtreecommitdiff
path: root/src/string/strchr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/string/strchr.c')
-rw-r--r--src/string/strchr.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/string/strchr.c b/src/string/strchr.c
index cde96cbf..fe4746f4 100644
--- a/src/string/strchr.c
+++ b/src/string/strchr.c
@@ -7,12 +7,15 @@ char * strchr(const char *s, int c)
{
SIGNAL_SAFE(0);
ASSERT_NONNULL(s);
+ DANGEROUS_READ(s, -1);
+ size_t len = strlen(s);
+ DANGER_OVER();
/*
RETURN_FAILURE(CONSTANT(NULL));
RETURN_SUCCESS(a pointer to the located character);
*/
- return (char*)memchr(s, (char)c, strlen(s));
+ return (char*)memchr(s, (char)c, len);
}
CHECK_2(char *, 0, strchr, const char *, int)