]> granicus.if.org Git - curl/commitdiff
darwinssl: Fix realloc memleak
authorDaniel Gustafsson <daniel@yesql.se>
Tue, 18 Sep 2018 07:06:07 +0000 (09:06 +0200)
committerDaniel Gustafsson <daniel@yesql.se>
Tue, 18 Sep 2018 07:08:06 +0000 (09:08 +0200)
The reallocation was using the input pointer for the return value, which
leads to a memory leak on reallication failure. Fix by instead use the
safe internal API call Curl_saferealloc().

Closes #3005
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
Reviewed-by: Nick Zitzmann <nickzman@gmail.com>
lib/vtls/darwinssl.c

index ae8a5cc1e8964d8c2973996ec5d92e1817c34866..3eee53a02d3122086a75e1c074beac8dcea264fc 100644 (file)
 #include "vtls.h"
 #include "darwinssl.h"
 #include "curl_printf.h"
+#include "strdup.h"
 
 #include "curl_memory.h"
 /* The last #include file should be: */
@@ -2056,7 +2057,7 @@ static int read_cert(const char *file, unsigned char **out, size_t *outlen)
 
     if(len + n >= cap) {
       cap *= 2;
-      data = realloc(data, cap);
+      data = Curl_saferealloc(data, cap);
       if(!data) {
         close(fd);
         return -1;