1818#include <pthread.h>
1919#include <stdlib.h>
2020#include <string.h>
21+ #include <strdup/strdup.h>
2122#include <url/url.h>
2223
2324static debug_t _debugger ;
@@ -93,7 +94,7 @@ http_get_response_t *repository_fetch_package_manifest(const char *package_url,
9394 char * authentication_header = malloc (size );
9495 snprintf (authentication_header , size , "%s:%s" , key , secret );
9596
96- res = http_get_shared (manifest_url , clib_package_curl_share , & authentication_header , 1 );
97+ res = http_get_shared (manifest_url , clib_package_curl_share , ( const char * * ) & authentication_header , 1 );
9798 } else {
9899 res = http_get_shared (manifest_url , clib_package_curl_share , NULL , 0 );
99100 }
@@ -136,7 +137,8 @@ static int fetch_package_file_work(const char *url, const char *dir, const char
136137 return 1 ;
137138 }
138139
139- if (!(path = path_join (dir , basename (file )))) {
140+ char * file_copy = strdup (file );
141+ if (!(path = path_join (dir , basename (file_copy )))) {
140142 rc = 1 ;
141143 goto cleanup ;
142144 }
@@ -159,7 +161,7 @@ static int fetch_package_file_work(const char *url, const char *dir, const char
159161 char * authentication_header = malloc (size );
160162 snprintf (authentication_header , size , "%s:%s" , key , secret );
161163
162- rc = http_get_file_shared (url , path , clib_package_curl_share , & authentication_header , 1 );
164+ rc = http_get_file_shared (url , path , clib_package_curl_share , ( const char * * ) & authentication_header , 1 );
163165 } else {
164166 rc = http_get_file_shared (url , path , clib_package_curl_share , NULL , 0 );
165167 }
@@ -195,8 +197,9 @@ static int fetch_package_file_work(const char *url, const char *dir, const char
195197 }
196198
197199cleanup :
198-
199200 free (path );
201+ free (file_copy );
202+
200203 return rc ;
201204}
202205
@@ -226,7 +229,7 @@ static int fetch_package_file(const char *url, const char *dir, const char *file
226229
227230 memset (fetch , 0 , sizeof (* fetch ));
228231
229- fetch -> url = url ;
232+ fetch -> url = strdup ( url ) ;
230233 fetch -> dir = dir ;
231234 fetch -> file = file ;
232235 fetch -> secret = secret ;
0 commit comments