From 20e9fc73e2c073c49e88b72fb5e07a0bb62b6d9d Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 6 Feb 2008 19:01:13 +0000 Subject: Fix problem in strdup replacement when dealing with absolutely huge strings. --- lib/strdup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/strdup.c b/lib/strdup.c index 97a4890e0..eef9e08ec 100644 --- a/lib/strdup.c +++ b/lib/strdup.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2007, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2008, Daniel Stenberg, , et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -27,13 +27,17 @@ #ifndef HAVE_STRDUP char *curlx_strdup(const char *str) { - int len; + size_t len; char *newstr; if(!str) return (char *)NULL; len = strlen(str); + + if(len >= ((size_t)-1) / sizeof(char)) + return (char *)NULL; + newstr = (char *) malloc((len+1)*sizeof(char)); if(!newstr) return (char *)NULL; -- cgit v1.2.3