Fix possible segfault in strnlen()

diff --git a/klibc/strnlen.c b/klibc/strnlen.c
index d0aa9cb..06b54c3 100644
--- a/klibc/strnlen.c
+++ b/klibc/strnlen.c
@@ -7,7 +7,10 @@
 size_t strnlen(const char *s, size_t maxlen)
 {
   const char *ss = s;
-  while(*ss && (maxlen > 0)) {
+
+  /* Important: the maxlen test must precede the reference through ss;
+     since the byte beyond the maximum may segfault */
+  while ((maxlen > 0) && *ss) {
 	ss++;
 	maxlen--;
   }