From 4c34af4c99d4e7385e341f5fe65cb42549ada152 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 4 Jan 2020 11:41:35 +0100 Subject: curl -w: handle a blank input file correctly Previously it would end up with an uninitialized memory buffer that would lead to a crash or junk getting output. Added test 1271 to verify. Reported-by: Brian Carpenter Closes #4786 --- src/tool_paramhlp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tool_paramhlp.c b/src/tool_paramhlp.c index de1b26d70..67702ebe2 100644 --- a/src/tool_paramhlp.c +++ b/src/tool_paramhlp.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2019, Daniel Stenberg, , et al. + * Copyright (C) 1998 - 2020, 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 @@ -65,7 +65,7 @@ ParameterError file2string(char **bufp, FILE *file) size_t alloc_needed; char buffer[256]; size_t stringlen = 0; - string = malloc(alloc); + string = calloc(1, alloc); if(!string) return PARAM_NO_MEM; -- cgit v1.2.3