summaryrefslogtreecommitdiff
path: root/drivers/builtin_openssl2/crypto/buffer/buf_str.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/builtin_openssl2/crypto/buffer/buf_str.c')
-rw-r--r--drivers/builtin_openssl2/crypto/buffer/buf_str.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/builtin_openssl2/crypto/buffer/buf_str.c b/drivers/builtin_openssl2/crypto/buffer/buf_str.c
index 233af246e4..fa0d608e76 100644
--- a/drivers/builtin_openssl2/crypto/buffer/buf_str.c
+++ b/drivers/builtin_openssl2/crypto/buffer/buf_str.c
@@ -61,6 +61,15 @@
#include <limits.h>
#include <openssl/buffer.h>
+size_t BUF_strnlen(const char *str, size_t maxlen)
+{
+ const char *p;
+
+ for (p = str; maxlen-- != 0 && *p != '\0'; ++p) ;
+
+ return p - str;
+}
+
char *BUF_strdup(const char *str)
{
if (str == NULL)
@@ -75,6 +84,8 @@ char *BUF_strndup(const char *str, size_t siz)
if (str == NULL)
return NULL;
+ siz = BUF_strnlen(str, siz);
+
if (siz >= INT_MAX)
return NULL;