From 2b4aeed39281e211870423e2ee9fa14f1d1fe072 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 25 Mar 2010 11:26:13 +1100 Subject: [PATCH] use strnlen() in the replacement for strndup() Using strlen() could lead to a segmentation fault with gcc on OpenSolaris --- util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util.c b/util.c index 56deaac..cdfbeef 100644 --- a/util.c +++ b/util.c @@ -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) {