summaryrefslogtreecommitdiff
path: root/drivers/builtin_openssl2/crypto/buffer/buf_str.c
diff options
context:
space:
mode:
authormrezai <mhd.rezai@gmail.com>2016-04-15 19:03:35 +0430
committermrezai <mhd.rezai@gmail.com>2016-04-15 19:03:35 +0430
commite97922f22038e9049ed4c2db5b3736dfaa0edde3 (patch)
tree37e036a343e7482a387b7acd0a88509af78a69eb /drivers/builtin_openssl2/crypto/buffer/buf_str.c
parent880f4abda44a42532abb6f15999a90bc85f6264a (diff)
Update OpenSSL to version 1.0.2g
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;