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.
This commit is contained in:
Eelco Dolstra 2017-04-28 15:10:29 +02:00
parent 39b08f4c0c
commit 41c4558afe
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE

View file

@ -224,7 +224,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);