summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commonlib/bsd/string.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/commonlib/bsd/string.c b/src/commonlib/bsd/string.c
index 16cd4b5e1d..56670e8862 100644
--- a/src/commonlib/bsd/string.c
+++ b/src/commonlib/bsd/string.c
@@ -15,12 +15,10 @@ size_t strlen(const char *str)
size_t strnlen(const char *str, size_t maxlen)
{
- const char *ptr = str;
- const char *end = str + maxlen + 1;
-
- while (*ptr++ && ptr < end)
- ;
- return ptr - str - 1;
+ size_t len = 0;
+ while (*str++ && len < maxlen)
+ len++;
+ return len;
}
char *strcat(char *dst, const char *src)