Fix hash computation when importing NARs greater than 4 GiB

This caused "nix-store --import" to compute an incorrect hash on NARs
that don't fit in an unsigned int. The import would succeed, but
"nix-store --verify-path" or subsequent exports would detect an
incorrect hash.

A deeper issue is that the export/import format does not contain a
hash, so we can't detect such issues early.

Also, I learned that -Wall does not warn about this.

(cherry picked from commit 41c4558afe)
This commit is contained in:
Eelco Dolstra 2017-04-28 15:10:29 +02:00
parent 5d59ec86d4
commit 26f7e8305b
No known key found for this signature in database
GPG Key ID: 8170B4726D7198DE
1 changed files with 1 additions and 1 deletions

View File

@ -205,7 +205,7 @@ static void start(HashType ht, Ctx & ctx)
static void update(HashType ht, Ctx & ctx,
const unsigned char * bytes, unsigned int len)
const unsigned char * bytes, size_t len)
{
if (ht == htMD5) MD5_Update(&ctx.md5, bytes, len);
else if (ht == htSHA1) SHA1_Update(&ctx.sha1, bytes, len);