From 0c5028faea7e5c08c920f8ea31f02e7923b8c2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 18 Dec 2013 21:48:57 +0100 Subject: daemon: Fix 'HashSink::currentHash()'. Before that, calls to 'HashSink::currentHash()' would eventually lead to a segfault because the underlying gcrypt handle has been closed. (Note that this method is only used via 'importPaths' and 'exportPath', though.) * nix/libutil/gcrypt-hash.hh (struct guix_hash_context): Add a constructor and a copy constructor; move out of 'extern "C"'. * nix/libutil/gcrypt-hash.cc (guix_hash_final): Clear 'md_handle' upon exit. * nix/sync-with-upstream (top_srcdir): Change hash.{cc,hh} to read 'struct Ctx' instead of 'union Ctx'. --- nix/libutil/gcrypt-hash.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'nix/libutil/gcrypt-hash.cc') diff --git a/nix/libutil/gcrypt-hash.cc b/nix/libutil/gcrypt-hash.cc index 553f633b93..c4ae7bfcc2 100644 --- a/nix/libutil/gcrypt-hash.cc +++ b/nix/libutil/gcrypt-hash.cc @@ -45,6 +45,7 @@ guix_hash_final (void *resbuf, struct guix_hash_context *ctx, memcpy (resbuf, gcry_md_read (ctx->md_handle, algo), gcry_md_get_algo_dlen (algo)); gcry_md_close (ctx->md_handle); + ctx->md_handle = NULL; } } -- cgit v1.2.3