aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-03-29 10:11:01 -0300
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2017-03-29 10:11:01 -0300
commit1ebc5c3ee814650e6be7603736bdbb60d8b84fef (patch)
treea5cff1d3c4e5e4f66ac9ce67383861ce2aa86af8
parentecore_con: remove warnings if FD_CLOEXEC is undefined. (diff)
downloadefl-1ebc5c3ee814650e6be7603736bdbb60d8b84fef.tar.gz
evil_string: fix strndup() for non-NULL terminated strings.devs/barbieri/efl_net_socket_windows2
If the given string is not null-terminated, then strlen() will go out of boundaries, we must limit the lookup to given 'n' parameter. To do so use strnlen(), that is a strlen() bounded by a maximum size.
-rw-r--r--src/lib/evil/evil_string.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/lib/evil/evil_string.c b/src/lib/evil/evil_string.c
index 634565b77a..4534b72437 100644
--- a/src/lib/evil/evil_string.c
+++ b/src/lib/evil/evil_string.c
@@ -18,10 +18,9 @@
char *
strndup(const char *str, size_t n)
{
- size_t slen = strlen(str);
+ size_t slen = strnlen(str, n);
char *ret;
- if (slen > n) slen = n;
ret = malloc (slen + 1);
if (!ret) return NULL;