about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-04-28T13·10+0200
committerEelco Dolstra <edolstra@gmail.com>2017-04-28T13·24+0200
commit41c4558afe04d1cad0d0ef3b18a1a8155b40b06e (patch)
tree22ea76ca305ae3bebf07ab31f426191c9cac6d0e /src/libutil
parent39b08f4c0c8851d96daa2b7d4e674b13c75afec7 (diff)
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.
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/hash.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc
index 9f4afd93c2fc..fa1bb5d97183 100644
--- a/src/libutil/hash.cc
+++ b/src/libutil/hash.cc
@@ -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);