Check length first in BUF_strnlen().
authorBen Laurie <ben@links.org>
Thu, 22 May 2014 09:11:40 +0000 (10:11 +0100)
committerBen Laurie <ben@links.org>
Thu, 22 May 2014 09:12:10 +0000 (10:12 +0100)
crypto/buffer/buf_str.c

index 60dab54344ce98d89b669df50abeb1f140dba87a..12ef1fa0649694d68bd7565f3112a9c6cdc77967 100644 (file)
@@ -64,7 +64,7 @@ size_t BUF_strnlen(const char *str, size_t maxlen)
        {
        const char *p;
 
-       for (p = str; *p != '\0' && maxlen-- != 0; ++p)
+       for (p = str; maxlen-- != 0 && *p != '\0'; ++p)
                ;
 
        return p - str;