use strnlen() in the replacement for strndup()

Using strlen() could lead to a segmentation fault with gcc on
OpenSolaris
This commit is contained in:
Andrew Tridgell 2010-03-25 11:26:13 +11:00
parent 574ab5a9af
commit 2b4aeed392

2
util.c
View File

@ -367,7 +367,7 @@ char *x_strndup(const char *s, size_t n)
if (!s)
return NULL;
m = strlen(s);
m = strnlen(s, n);
m = n < m ? n : m;
ret = malloc(m + 1);
if (ret) {