Move from strlen to strnlen_s.

Change-Id: I1d25a65e020b45b556723de14ef55a6140229dbb
diff --git a/src/arch/aarch64/std.c b/src/arch/aarch64/std.c
index a3a0a93..3534702 100644
--- a/src/arch/aarch64/std.c
+++ b/src/arch/aarch64/std.c
@@ -27,20 +27,6 @@
 	return s;
 }
 
-/*
- * Calculates the length of the provided null-terminated string.
- */
-size_t strlen(const char *str)
-{
-	const char *p = str;
-
-	while (*p) {
-		p++;
-	}
-
-	return p - str;
-}
-
 void *memcpy(void *dst, const void *src, size_t n)
 {
 	char *x = dst;
diff --git a/src/dlog.c b/src/dlog.c
index cd1247b..f853d6e 100644
--- a/src/dlog.c
+++ b/src/dlog.c
@@ -91,7 +91,7 @@
 	}
 
 	/* Fill until we reach the desired length. */
-	len += strlen(suffix);
+	len += strnlen_s(suffix, 50);
 	while (len < width) {
 		arch_putchar(fill);
 		len++;
diff --git a/src/memiter.c b/src/memiter.c
index 7ec3c94..5ff54ee 100644
--- a/src/memiter.c
+++ b/src/memiter.c
@@ -58,9 +58,10 @@
  */
 bool memiter_iseq(const struct memiter *it, const char *str)
 {
-	size_t len = strlen(str);
+	size_t it_len = it->limit - it->next;
+	size_t len = strnlen_s(str, it_len + 1);
 
-	if (len != it->limit - it->next) {
+	if (len != it_len) {
 		return false;
 	}
 
diff --git a/src/std.c b/src/std.c
index fd52a0f..9f829e8 100644
--- a/src/std.c
+++ b/src/std.c
@@ -100,3 +100,18 @@
 fail:
 	panic("memmove_s failure");
 }
+
+size_t strnlen_s(const char *str, size_t strsz)
+{
+	const char *p = str;
+
+	if (str == NULL) {
+		return 0;
+	}
+
+	while (*p && strsz--) {
+		p++;
+	}
+
+	return p - str;
+}