X-Git-Url: https://wimlib.net/git/?p=wimlib;a=blobdiff_plain;f=src%2Fresource.c;h=dc5b7a806fe24d3bb61aad2bb5528ffd787e2a18;hp=5237b88a37fd646613770df5768e3f56625cd2ab;hb=7ce0d372fae285051cbc9740c9fa316d22465d9d;hpb=f3e97b29c4a8c564d54b0fd11cd43a9b4cd6a8ad diff --git a/src/resource.c b/src/resource.c index 5237b88a..dc5b7a80 100644 --- a/src/resource.c +++ b/src/resource.c @@ -593,7 +593,11 @@ read_partial_wim_resource(const struct wim_lookup_table_entry *lte, } goto out_release_fp; read_error: - ERROR_WITH_ERRNO("Error reading data from WIM"); + if (ferror(wim_fp)) { + ERROR_WITH_ERRNO("Error reading data from WIM"); + } else { + ERROR("Unexpected EOF in WIM!"); + } ret = WIMLIB_ERR_READ; out_release_fp: if (flags & WIMLIB_RESOURCE_FLAG_THREADSAFE_READ) @@ -838,6 +842,28 @@ extract_wim_resource_to_fd(const struct wim_lookup_table_entry *lte, return extract_wim_resource(lte, size, extract_wim_chunk_to_fd, &fd); } + +static int +sha1_chunk(const void *buf, size_t len, void *ctx) +{ + sha1_update(ctx, buf, len); + return 0; +} + +int +sha1_resource(struct wim_lookup_table_entry *lte) +{ + int ret; + SHA_CTX sha_ctx; + + sha1_init(&sha_ctx); + ret = read_resource_prefix(lte, wim_resource_size(lte), + sha1_chunk, &sha_ctx, 0); + if (ret == 0) + sha1_final(lte->hash, &sha_ctx); + return ret; +} + /* * Copies the file resource specified by the lookup table entry @lte from the * input WIM to the output WIM that has its FILE * given by