18
18
#include <pthread.h>
19
19
#include <stdlib.h>
20
20
#include <string.h>
21
+ #include <strdup/strdup.h>
21
22
#include <url/url.h>
22
23
23
24
static debug_t _debugger ;
@@ -93,7 +94,7 @@ http_get_response_t *repository_fetch_package_manifest(const char *package_url,
93
94
char * authentication_header = malloc (size );
94
95
snprintf (authentication_header , size , "%s:%s" , key , secret );
95
96
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 );
97
98
} else {
98
99
res = http_get_shared (manifest_url , clib_package_curl_share , NULL , 0 );
99
100
}
@@ -136,7 +137,8 @@ static int fetch_package_file_work(const char *url, const char *dir, const char
136
137
return 1 ;
137
138
}
138
139
139
- if (!(path = path_join (dir , basename (file )))) {
140
+ char * file_copy = strdup (file );
141
+ if (!(path = path_join (dir , basename (file_copy )))) {
140
142
rc = 1 ;
141
143
goto cleanup ;
142
144
}
@@ -159,7 +161,7 @@ static int fetch_package_file_work(const char *url, const char *dir, const char
159
161
char * authentication_header = malloc (size );
160
162
snprintf (authentication_header , size , "%s:%s" , key , secret );
161
163
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 );
163
165
} else {
164
166
rc = http_get_file_shared (url , path , clib_package_curl_share , NULL , 0 );
165
167
}
@@ -195,8 +197,9 @@ static int fetch_package_file_work(const char *url, const char *dir, const char
195
197
}
196
198
197
199
cleanup :
198
-
199
200
free (path );
201
+ free (file_copy );
202
+
200
203
return rc ;
201
204
}
202
205
@@ -226,7 +229,7 @@ static int fetch_package_file(const char *url, const char *dir, const char *file
226
229
227
230
memset (fetch , 0 , sizeof (* fetch ));
228
231
229
- fetch -> url = url ;
232
+ fetch -> url = strdup ( url ) ;
230
233
fetch -> dir = dir ;
231
234
fetch -> file = file ;
232
235
fetch -> secret = secret ;
0 commit comments