From 9f7f7925da648b3b39714e6c9fd65500a869bdfe Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 22 May 2012 01:40:11 +0900 Subject: Check checksum of downloaded file if checksum is available Metalink file contains several hash types of checksums, such as md5, sha-1, sha-256, etc. To deal with these checksums, I created abstraction layer based on lib/curl_md5.h and lib/md5.c. Basically, they are almost the same but I changed the code so that it is not hash type dependent. Currently, GNUTLS(nettle or gcrypt) and OpenSSL functions are supported. Checksum checking is done by reopening download file. If there is an I/O error, the current implementation just prints error message and does not try next resource. In this patch, the supported hash types are: md5, sha-1 and sha-256. --- src/tool_operate.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/tool_operate.c') diff --git a/src/tool_operate.c b/src/tool_operate.c index 0d17329b0..be860b983 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -1594,6 +1594,12 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) fprintf(config->errors, "Could not parse Metalink file.\n"); } } + else if(metalink && res == CURLE_OK && !metalink_next_res) { + int rv = metalink_check_hash(config, mlfile, outs.filename); + if(rv == 0) { + metalink_next_res = 1; + } + } #endif /* HAVE_LIBMETALINK */ /* No more business with this output struct */ @@ -1619,6 +1625,9 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[]) break; } if(!metalink_next_res || *(++mlres) == NULL) + /* TODO If metalink_next_res is 1 and mlres is NULL, + * set res to error code + */ break; } else -- cgit v1.2.3