From b15a83ceb1f20cae0587f93e8279ac376552fa8f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 12 Dec 2010 21:16:31 +0000 Subject: fixed problematic usage of strndup git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@58 e61f0598-a718-4e21-a8f0-0aadfa62ad6b --- src/cfg_parser.rl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/cfg_parser.rl') diff --git a/src/cfg_parser.rl b/src/cfg_parser.rl index 07027f7..39836ab 100644 --- a/src/cfg_parser.rl +++ b/src/cfg_parser.rl @@ -86,10 +86,14 @@ static int owrt_string(char** dest, char* start, char* end) return -1; if(*dest) free(*dest); - *dest = strndup(start, end - start); + int n = end - start; + *dest = malloc(n+1); if(!(*dest)) return -2; + memcpy(*dest, start, n); + (*dest)[n] = 0; + return 0; } -- cgit v1.2.3