From: Andrew Tridgell Date: Thu, 25 Mar 2010 00:26:13 +0000 (+1100) Subject: use strnlen() in the replacement for strndup() X-Git-Tag: v3.0pre1~85^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=2b4aeed39281e211870423e2ee9fa14f1d1fe072;p=thirdparty%2Fccache.git use strnlen() in the replacement for strndup() Using strlen() could lead to a segmentation fault with gcc on OpenSolaris --- diff --git a/util.c b/util.c index 56deaacd8..cdfbeefba 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) {