1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
22 #include "tool_setup.h"
34 # include <openssl/md5.h>
35 # include <openssl/sha.h>
36 #elif defined(USE_GNUTLS_NETTLE)
37 # include <nettle/md5.h>
38 # include <nettle/sha.h>
39 # define MD5_CTX struct md5_ctx
40 # define SHA_CTX struct sha1_ctx
41 # define SHA256_CTX struct sha256_ctx
42 #elif defined(USE_GNUTLS)
44 # define MD5_CTX gcry_md_hd_t
45 # define SHA_CTX gcry_md_hd_t
46 # define SHA256_CTX gcry_md_hd_t
47 #elif defined(USE_NSS)
50 # define MD5_CTX void *
51 # define SHA_CTX void *
52 # define SHA256_CTX void *
53 static NSSInitContext *nss_context;
54 #elif defined(USE_POLARSSL)
55 # include <polarssl/md5.h>
56 # include <polarssl/sha1.h>
57 # include <polarssl/sha256.h>
58 # define MD5_CTX md5_context
59 # define SHA_CTX sha1_context
60 # define SHA256_CTX sha256_context
61 #elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \
62 (__MAC_OS_X_VERSION_MAX_ALLOWED >= 1040)) || \
63 (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && \
64 (__IPHONE_OS_VERSION_MAX_ALLOWED >= 20000))
65 /* For Apple operating systems: CommonCrypto has the functions we need.
66 The library's headers are even backward-compatible with OpenSSL's
67 headers as long as we define COMMON_DIGEST_FOR_OPENSSL first.
69 These functions are available on Tiger and later, as well as iOS 2.0
70 and later. If you're building for an older cat, well, sorry. */
71 # define COMMON_DIGEST_FOR_OPENSSL
72 # include <CommonCrypto/CommonDigest.h>
74 /* For Windows: If no other crypto library is provided, we fallback
75 to the hash functions provided within the Microsoft Windows CryptoAPI */
76 # include <wincrypt.h>
77 /* Custom structure in order to store the required provider and hash handle */
78 struct win32_crypto_hash {
79 HCRYPTPROV hCryptProv;
82 /* Custom Microsoft AES Cryptographic Provider defines required for MinGW */
83 # ifndef ALG_SID_SHA_256
84 # define ALG_SID_SHA_256 12
87 # define CALG_SHA_256 (ALG_CLASS_HASH | ALG_TYPE_ANY | ALG_SID_SHA_256)
89 # define MD5_CTX struct win32_crypto_hash
90 # define SHA_CTX struct win32_crypto_hash
91 # define SHA256_CTX struct win32_crypto_hash
93 # error "Can't compile METALINK support without a crypto library."
96 #define ENABLE_CURLX_PRINTF
97 /* use our own printf() functions */
100 #include "tool_getparam.h"
101 #include "tool_paramhlp.h"
102 #include "tool_cfgable.h"
103 #include "tool_metalink.h"
104 #include "tool_msgs.h"
106 #include "memdebug.h" /* keep this as LAST include */
108 /* Copied from tool_getparam.c */
109 #define GetStr(str,val) do { \
115 *(str) = strdup((val)); \
117 return PARAM_NO_MEM; \
120 #ifdef USE_GNUTLS_NETTLE
122 static int MD5_Init(MD5_CTX *ctx)
128 static void MD5_Update(MD5_CTX *ctx,
129 const unsigned char *input,
130 unsigned int inputLen)
132 md5_update(ctx, inputLen, input);
135 static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
137 md5_digest(ctx, 16, digest);
140 static int SHA1_Init(SHA_CTX *ctx)
146 static void SHA1_Update(SHA_CTX *ctx,
147 const unsigned char *input,
148 unsigned int inputLen)
150 sha1_update(ctx, inputLen, input);
153 static void SHA1_Final(unsigned char digest[20], SHA_CTX *ctx)
155 sha1_digest(ctx, 20, digest);
158 static int SHA256_Init(SHA256_CTX *ctx)
164 static void SHA256_Update(SHA256_CTX *ctx,
165 const unsigned char *input,
166 unsigned int inputLen)
168 sha256_update(ctx, inputLen, input);
171 static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
173 sha256_digest(ctx, 32, digest);
176 #elif defined(USE_GNUTLS)
178 static int MD5_Init(MD5_CTX *ctx)
180 gcry_md_open(ctx, GCRY_MD_MD5, 0);
184 static void MD5_Update(MD5_CTX *ctx,
185 const unsigned char *input,
186 unsigned int inputLen)
188 gcry_md_write(*ctx, input, inputLen);
191 static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
193 memcpy(digest, gcry_md_read(*ctx, 0), 16);
197 static int SHA1_Init(SHA_CTX *ctx)
199 gcry_md_open(ctx, GCRY_MD_SHA1, 0);
203 static void SHA1_Update(SHA_CTX *ctx,
204 const unsigned char *input,
205 unsigned int inputLen)
207 gcry_md_write(*ctx, input, inputLen);
210 static void SHA1_Final(unsigned char digest[20], SHA_CTX *ctx)
212 memcpy(digest, gcry_md_read(*ctx, 0), 20);
216 static int SHA256_Init(SHA256_CTX *ctx)
218 gcry_md_open(ctx, GCRY_MD_SHA256, 0);
222 static void SHA256_Update(SHA256_CTX *ctx,
223 const unsigned char *input,
224 unsigned int inputLen)
226 gcry_md_write(*ctx, input, inputLen);
229 static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
231 memcpy(digest, gcry_md_read(*ctx, 0), 32);
235 #elif defined(USE_NSS)
237 static int nss_hash_init(void **pctx, SECOidTag hash_alg)
241 /* we have to initialize NSS if not initialized alraedy */
242 if(!NSS_IsInitialized() && !nss_context) {
243 static NSSInitParameters params;
244 params.length = sizeof params;
245 nss_context = NSS_InitContext("", "", "", "", ¶ms, NSS_INIT_READONLY
246 | NSS_INIT_NOCERTDB | NSS_INIT_NOMODDB | NSS_INIT_FORCEOPEN
247 | NSS_INIT_NOROOTINIT | NSS_INIT_OPTIMIZESPACE | NSS_INIT_PK11RELOAD);
250 ctx = PK11_CreateDigestContext(hash_alg);
252 return /* failure */ 0;
254 if(PK11_DigestBegin(ctx) != SECSuccess) {
255 PK11_DestroyContext(ctx, PR_TRUE);
256 return /* failure */ 0;
260 return /* success */ 1;
263 static void nss_hash_final(void **pctx, unsigned char *out, unsigned int len)
265 PK11Context *ctx = *pctx;
267 PK11_DigestFinal(ctx, out, &outlen, len);
268 PK11_DestroyContext(ctx, PR_TRUE);
271 static int MD5_Init(MD5_CTX *pctx)
273 return nss_hash_init(pctx, SEC_OID_MD5);
276 static void MD5_Update(MD5_CTX *pctx,
277 const unsigned char *input,
278 unsigned int input_len)
280 PK11_DigestOp(*pctx, input, input_len);
283 static void MD5_Final(unsigned char digest[16], MD5_CTX *pctx)
285 nss_hash_final(pctx, digest, 16);
288 static int SHA1_Init(SHA_CTX *pctx)
290 return nss_hash_init(pctx, SEC_OID_SHA1);
293 static void SHA1_Update(SHA_CTX *pctx,
294 const unsigned char *input,
295 unsigned int input_len)
297 PK11_DigestOp(*pctx, input, input_len);
300 static void SHA1_Final(unsigned char digest[20], SHA_CTX *pctx)
302 nss_hash_final(pctx, digest, 20);
305 static int SHA256_Init(SHA256_CTX *pctx)
307 return nss_hash_init(pctx, SEC_OID_SHA256);
310 static void SHA256_Update(SHA256_CTX *pctx,
311 const unsigned char *input,
312 unsigned int input_len)
314 PK11_DigestOp(*pctx, input, input_len);
317 static void SHA256_Final(unsigned char digest[32], SHA256_CTX *pctx)
319 nss_hash_final(pctx, digest, 32);
322 #elif defined(USE_POLARSSL)
324 static int MD5_Init(MD5_CTX *ctx)
330 static void MD5_Update(MD5_CTX *ctx,
331 const unsigned char *input,
332 unsigned int inputLen)
334 md5_update(ctx, input, inputLen);
337 static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
339 md5_finish(ctx, digest);
342 static int SHA1_Init(SHA_CTX *ctx)
348 static void SHA1_Update(SHA_CTX *ctx,
349 const unsigned char *input,
350 unsigned int inputLen)
352 sha1_update(ctx, input, inputLen);
355 static void SHA1_Final(unsigned char digest[20], SHA_CTX *ctx)
357 sha1_finish(ctx, digest);
360 static int SHA256_Init(SHA256_CTX *ctx)
362 sha256_starts(ctx, 0); /* 0 = sha256 */
366 static void SHA256_Update(SHA256_CTX *ctx,
367 const unsigned char *input,
368 unsigned int inputLen)
370 sha256_update(ctx, input, inputLen);
373 static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
375 sha256_finish(ctx, digest);
378 #elif defined(_WIN32) && !defined(USE_OPENSSL)
380 static void win32_crypto_final(struct win32_crypto_hash *ctx,
381 unsigned char *digest,
382 unsigned int digestLen)
384 unsigned long length;
385 CryptGetHashParam(ctx->hHash, HP_HASHVAL, NULL, &length, 0);
386 if(length == digestLen)
387 CryptGetHashParam(ctx->hHash, HP_HASHVAL, digest, &length, 0);
389 CryptDestroyHash(ctx->hHash);
391 CryptReleaseContext(ctx->hCryptProv, 0);
394 static int MD5_Init(MD5_CTX *ctx)
396 if(CryptAcquireContext(&ctx->hCryptProv, NULL, NULL,
397 PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
398 CryptCreateHash(ctx->hCryptProv, CALG_MD5, 0, 0, &ctx->hHash);
403 static void MD5_Update(MD5_CTX *ctx,
404 const unsigned char *input,
405 unsigned int inputLen)
407 CryptHashData(ctx->hHash, (unsigned char *)input, inputLen, 0);
410 static void MD5_Final(unsigned char digest[16], MD5_CTX *ctx)
412 win32_crypto_final(ctx, digest, 16);
415 static int SHA1_Init(SHA_CTX *ctx)
417 if(CryptAcquireContext(&ctx->hCryptProv, NULL, NULL,
418 PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
419 CryptCreateHash(ctx->hCryptProv, CALG_SHA1, 0, 0, &ctx->hHash);
424 static void SHA1_Update(SHA_CTX *ctx,
425 const unsigned char *input,
426 unsigned int inputLen)
428 CryptHashData(ctx->hHash, (unsigned char *)input, inputLen, 0);
431 static void SHA1_Final(unsigned char digest[20], SHA_CTX *ctx)
433 win32_crypto_final(ctx, digest, 20);
436 static int SHA256_Init(SHA256_CTX *ctx)
438 if(CryptAcquireContext(&ctx->hCryptProv, NULL, NULL,
439 PROV_RSA_AES, CRYPT_VERIFYCONTEXT)) {
440 CryptCreateHash(ctx->hCryptProv, CALG_SHA_256, 0, 0, &ctx->hHash);
445 static void SHA256_Update(SHA256_CTX *ctx,
446 const unsigned char *input,
447 unsigned int inputLen)
449 CryptHashData(ctx->hHash, (unsigned char *)input, inputLen, 0);
452 static void SHA256_Final(unsigned char digest[32], SHA256_CTX *ctx)
454 win32_crypto_final(ctx, digest, 32);
457 #endif /* CRYPTO LIBS */
459 const digest_params MD5_DIGEST_PARAMS[] = {
461 (Curl_digest_init_func) MD5_Init,
462 (Curl_digest_update_func) MD5_Update,
463 (Curl_digest_final_func) MD5_Final,
469 const digest_params SHA1_DIGEST_PARAMS[] = {
471 (Curl_digest_init_func) SHA1_Init,
472 (Curl_digest_update_func) SHA1_Update,
473 (Curl_digest_final_func) SHA1_Final,
479 const digest_params SHA256_DIGEST_PARAMS[] = {
481 (Curl_digest_init_func) SHA256_Init,
482 (Curl_digest_update_func) SHA256_Update,
483 (Curl_digest_final_func) SHA256_Final,
489 static const metalink_digest_def SHA256_DIGEST_DEF[] = {
490 {"sha-256", SHA256_DIGEST_PARAMS}
493 static const metalink_digest_def SHA1_DIGEST_DEF[] = {
494 {"sha-1", SHA1_DIGEST_PARAMS}
497 static const metalink_digest_def MD5_DIGEST_DEF[] = {
498 {"md5", MD5_DIGEST_PARAMS}
502 * The alias of supported hash functions in the order by preference
503 * (basically stronger hash comes first). We included "sha-256" and
504 * "sha256". The former is the name defined in the IANA registry named
505 * "Hash Function Textual Names". The latter is widely (and
506 * historically) used in Metalink version 3.
508 static const metalink_digest_alias digest_aliases[] = {
509 {"sha-256", SHA256_DIGEST_DEF},
510 {"sha256", SHA256_DIGEST_DEF},
511 {"sha-1", SHA1_DIGEST_DEF},
512 {"sha1", SHA1_DIGEST_DEF},
513 {"md5", MD5_DIGEST_DEF},
517 digest_context *Curl_digest_init(const digest_params *dparams)
519 digest_context *ctxt;
521 /* Create digest context */
522 ctxt = malloc(sizeof *ctxt);
527 ctxt->digest_hashctx = malloc(dparams->digest_ctxtsize);
529 if(!ctxt->digest_hashctx) {
534 ctxt->digest_hash = dparams;
536 if(dparams->digest_init(ctxt->digest_hashctx) != 1) {
544 int Curl_digest_update(digest_context *context,
545 const unsigned char *data,
548 (*context->digest_hash->digest_update)(context->digest_hashctx, data, len);
553 int Curl_digest_final(digest_context *context, unsigned char *result)
555 (*context->digest_hash->digest_final)(result, context->digest_hashctx);
557 free(context->digest_hashctx);
563 static unsigned char hex_to_uint(const char *s)
570 val = strtoul(buf, NULL, 16);
571 return (unsigned char)(val&0xff);
575 * Check checksum of file denoted by filename. The expected hash value
576 * is given in hex_hash which is hex-encoded string.
578 * This function returns 1 if it succeeds or one of the following
582 * Checksum didn't match.
584 * Could not open file; or could not read data from file.
586 * Hash algorithm not available.
588 static int check_hash(const char *filename,
589 const metalink_digest_def *digest_def,
590 const unsigned char *digest, FILE *error)
592 unsigned char *result;
593 digest_context *dctx;
594 int check_ok, flags, fd;
598 /* O_BINARY is required in order to avoid binary EOF in text mode */
602 fd = open(filename, flags);
604 fprintf(error, "Metalink: validating (%s) [%s] FAILED (%s)\n", filename,
605 digest_def->hash_name, strerror(errno));
609 dctx = Curl_digest_init(digest_def->dparams);
611 fprintf(error, "Metalink: validating (%s) [%s] FAILED (%s)\n", filename,
612 digest_def->hash_name, "failed to initialize hash algorithm");
617 result = malloc(digest_def->dparams->digest_resultlen);
623 unsigned char buf[4096];
624 ssize_t len = read(fd, buf, sizeof(buf));
629 fprintf(error, "Metalink: validating (%s) [%s] FAILED (%s)\n", filename,
630 digest_def->hash_name, strerror(errno));
631 Curl_digest_final(dctx, result);
635 Curl_digest_update(dctx, buf, (unsigned int)len);
637 Curl_digest_final(dctx, result);
638 check_ok = memcmp(result, digest,
639 digest_def->dparams->digest_resultlen) == 0;
640 /* sha*sum style verdict output */
642 fprintf(error, "Metalink: validating (%s) [%s] OK\n", filename,
643 digest_def->hash_name);
645 fprintf(error, "Metalink: validating (%s) [%s] FAILED (digest mismatch)\n",
646 filename, digest_def->hash_name);
653 int metalink_check_hash(struct GlobalConfig *config,
654 metalinkfile *mlfile,
655 const char *filename)
658 fprintf(config->errors, "Metalink: validating (%s)...\n", filename);
659 if(mlfile->checksum == NULL) {
660 fprintf(config->errors,
661 "Metalink: validating (%s) FAILED (digest missing)\n", filename);
664 rv = check_hash(filename, mlfile->checksum->digest_def,
665 mlfile->checksum->digest, config->errors);
669 static metalink_checksum *new_metalink_checksum_from_hex_digest
670 (const metalink_digest_def *digest_def, const char *hex_digest)
672 metalink_checksum *chksum;
673 unsigned char *digest;
675 size_t len = strlen(hex_digest);
676 digest = malloc(len/2);
680 for(i = 0; i < len; i += 2) {
681 digest[i/2] = hex_to_uint(hex_digest+i);
683 chksum = malloc(sizeof(metalink_checksum));
685 chksum->digest_def = digest_def;
686 chksum->digest = digest;
691 static metalink_resource *new_metalink_resource(const char *url)
693 metalink_resource *res;
694 res = malloc(sizeof(metalink_resource));
697 res->url = strdup(url);
706 /* Returns nonzero if hex_digest is properly formatted; that is each
707 letter is in [0-9A-Za-z] and the length of the string equals to the
708 result length of digest * 2. */
709 static int check_hex_digest(const char *hex_digest,
710 const metalink_digest_def *digest_def)
713 for(i = 0; hex_digest[i]; ++i) {
714 char c = hex_digest[i];
715 if(!(('0' <= c && c <= '9') || ('a' <= c && c <= 'z') ||
716 ('A' <= c && c <= 'Z'))) {
720 return digest_def->dparams->digest_resultlen * 2 == i;
723 static metalinkfile *new_metalinkfile(metalink_file_t *fileinfo)
726 f = (metalinkfile*)malloc(sizeof(metalinkfile));
731 f->filename = strdup(fileinfo->name);
738 if(fileinfo->checksums) {
739 const metalink_digest_alias *digest_alias;
740 for(digest_alias = digest_aliases; digest_alias->alias_name;
742 metalink_checksum_t **p;
743 for(p = fileinfo->checksums; *p; ++p) {
744 if(curl_strequal(digest_alias->alias_name, (*p)->type) &&
745 check_hex_digest((*p)->hash, digest_alias->digest_def)) {
747 new_metalink_checksum_from_hex_digest(digest_alias->digest_def,
757 if(fileinfo->resources) {
758 metalink_resource_t **p;
759 metalink_resource root, *tail;
762 for(p = fileinfo->resources; *p; ++p) {
763 metalink_resource *res;
764 /* Filter by type if it is non-NULL. In Metalink v3, type
765 includes the type of the resource. In curl, we are only
766 interested in HTTP, HTTPS and FTP. In addition to them,
767 Metalink v3 file may contain bittorrent type URL, which
768 points to the BitTorrent metainfo file. We ignore it here.
769 In Metalink v4, type was deprecated and all
770 fileinfo->resources point to the target file. BitTorrent
771 metainfo file URL may be appeared in fileinfo->metaurls.
773 if((*p)->type == NULL ||
774 curl_strequal((*p)->type, "http") ||
775 curl_strequal((*p)->type, "https") ||
776 curl_strequal((*p)->type, "ftp") ||
777 curl_strequal((*p)->type, "ftps")) {
778 res = new_metalink_resource((*p)->url);
783 f->resource = root.next;
788 int parse_metalink(struct OperationConfig *config, struct OutStruct *outs,
789 const char *metalink_url)
792 metalink_t* metalink;
793 metalink_file_t **files;
794 bool warnings = FALSE;
796 /* metlaink_parse_final deletes outs->metalink_parser */
797 r = metalink_parse_final(outs->metalink_parser, NULL, 0, &metalink);
798 outs->metalink_parser = NULL;
802 if(metalink->files == NULL) {
803 fprintf(config->global->errors, "Metalink: parsing (%s) WARNING "
804 "(missing or invalid file name)\n",
806 metalink_delete(metalink);
809 for(files = metalink->files; *files; ++files) {
811 /* Skip an entry which has no resource. */
812 if(!(*files)->resources) {
813 fprintf(config->global->errors, "Metalink: parsing (%s) WARNING "
814 "(missing or invalid resource)\n",
815 metalink_url, (*files)->name);
818 if(config->url_get ||
819 ((config->url_get = config->url_list) != NULL)) {
820 /* there's a node here, if it already is filled-in continue to
821 find an "empty" node */
822 while(config->url_get && (config->url_get->flags & GETOUT_URL))
823 config->url_get = config->url_get->next;
826 /* now there might or might not be an available node to fill in! */
830 url = config->url_get;
832 /* there was no free node, create one! */
833 url = new_getout(config);
836 metalinkfile *mlfile = new_metalinkfile(*files);
840 if(!mlfile->checksum) {
842 fprintf(config->global->errors,
843 "Metalink: parsing (%s) WARNING (digest missing)\n",
846 /* Set name as url */
847 GetStr(&url->url, mlfile->filename);
849 /* set flag metalink here */
850 url->flags |= GETOUT_URL | GETOUT_METALINK;
852 if(config->metalinkfile_list) {
853 config->metalinkfile_last->next = mlfile;
854 config->metalinkfile_last = mlfile;
857 config->metalinkfile_list = config->metalinkfile_last = mlfile;
861 metalink_delete(metalink);
862 return (warnings) ? -2 : 0;
865 size_t metalink_write_cb(void *buffer, size_t sz, size_t nmemb,
868 struct OutStruct *outs = userdata;
869 struct OperationConfig *config = outs->config;
873 * Once that libcurl has called back tool_write_cb() the returned value
874 * is checked against the amount that was intended to be written, if
875 * it does not match then it fails with CURLE_WRITE_ERROR. So at this
876 * point returning a value different from sz*nmemb indicates failure.
878 const size_t failure = (sz * nmemb) ? 0 : 1;
883 rv = metalink_parse_update(outs->metalink_parser, buffer, sz *nmemb);
887 fprintf(config->global->errors, "Metalink: parsing FAILED\n");
893 * Returns nonzero if content_type includes mediatype.
895 static int check_content_type(const char *content_type, const char *media_type)
897 const char *ptr = content_type;
898 size_t media_type_len = strlen(media_type);
899 for(; *ptr && (*ptr == ' ' || *ptr == '\t'); ++ptr);
903 return curl_strnequal(ptr, media_type, media_type_len) &&
904 (*(ptr+media_type_len) == '\0' || *(ptr+media_type_len) == ' ' ||
905 *(ptr+media_type_len) == '\t' || *(ptr+media_type_len) == ';');
908 int check_metalink_content_type(const char *content_type)
910 return check_content_type(content_type, "application/metalink+xml");
913 int count_next_metalink_resource(metalinkfile *mlfile)
916 metalink_resource *res;
917 for(res = mlfile->resource; res; res = res->next, ++count);
921 static void delete_metalink_checksum(metalink_checksum *chksum)
926 Curl_safefree(chksum->digest);
927 Curl_safefree(chksum);
930 static void delete_metalink_resource(metalink_resource *res)
935 Curl_safefree(res->url);
939 static void delete_metalinkfile(metalinkfile *mlfile)
941 metalink_resource *res;
945 Curl_safefree(mlfile->filename);
946 delete_metalink_checksum(mlfile->checksum);
947 for(res = mlfile->resource; res;) {
948 metalink_resource *next;
950 delete_metalink_resource(res);
953 Curl_safefree(mlfile);
956 void clean_metalink(struct OperationConfig *config)
958 while(config->metalinkfile_list) {
959 metalinkfile *mlfile = config->metalinkfile_list;
960 config->metalinkfile_list = config->metalinkfile_list->next;
961 delete_metalinkfile(mlfile);
963 config->metalinkfile_last = 0;
966 void metalink_cleanup(void)
970 NSS_ShutdownContext(nss_context);
976 #endif /* USE_METALINK */