]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
use strnlen() in the replacement for strndup()
authorAndrew Tridgell <tridge@samba.org>
Thu, 25 Mar 2010 00:26:13 +0000 (11:26 +1100)
committerAndrew Tridgell <tridge@samba.org>
Thu, 25 Mar 2010 00:26:13 +0000 (11:26 +1100)
Using strlen() could lead to a segmentation fault with gcc on
OpenSolaris

util.c

diff --git a/util.c b/util.c
index 56deaacd8ee219071f50d4186bd07812651b5f5d..cdfbeefba11c47a5208effe9bceec07ed1c1fdcf 100644 (file)
--- 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) {