summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libc/string/strnlen.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/libc/string/strnlen.c b/src/lib/libc/string/strnlen.c
index 0c6df381fc..2dc7b4fb32 100644
--- a/src/lib/libc/string/strnlen.c
+++ b/src/lib/libc/string/strnlen.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: strnlen.c,v 1.2 2010/05/21 06:57:45 chl Exp $ */ 1/* $OpenBSD: strnlen.c,v 1.3 2010/06/02 12:58:12 millert Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com> 4 * Copyright (c) 2010 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -23,10 +23,9 @@
23size_t 23size_t
24strnlen(const char *str, size_t maxlen) 24strnlen(const char *str, size_t maxlen)
25{ 25{
26 const char *cp, *ep; 26 const char *cp;
27 27
28 ep = str + maxlen; 28 for (cp = str; maxlen != 0 && *cp != '\0'; cp++, maxlen--)
29 for (cp = str; cp < ep && *cp != '\0'; cp++)
30 ; 29 ;
31 30
32 return (size_t)(cp - str); 31 return (size_t)(cp - str);