[systemd-devel] hash context not closed.
vcaputo at pengaru.com
vcaputo at pengaru.com
Sat Feb 3 22:10:39 UTC 2018
On Sat, Feb 03, 2018 at 09:14:40PM +0100, Stef Bon wrote:
> The testing of the new code requires me too much (meson is required..
> and I don't want to replace my existing systemd) and I do not expect
> to add more patches is near future.
>
> I've got a patch:
>
> diff --git a/src/basic/gcrypt-util.c b/src/basic/gcrypt-util.c
> index 1bfb77672..c7c07e3b7 100644
> --- a/src/basic/gcrypt-util.c
> +++ b/src/basic/gcrypt-util.c
> @@ -46,6 +46,7 @@ int string_hashsum(const char *s, size_t len, int
> md_algorithm, char **out) {
> size_t hash_size;
> void *hash;
> char *enc;
> + int res=-EIO;
>
> initialize_libgcrypt(false);
>
> @@ -59,14 +60,24 @@ int string_hashsum(const char *s, size_t len, int
> md_algorithm, char **out) {
> gcry_md_write(md, s, len);
>
> hash = gcry_md_read(md, 0);
> +
> if (!hash)
> - return -EIO;
> + goto closemd;
>
> + res = -ENOMEM;
> enc = hexmem(hash, hash_size);
> - if (!enc)
> - return -ENOMEM;
>
> - *out = enc;
> - return 0;
> + if (enc) {
> +
> + *out = enc;
> + res = 0;
> +
> + }
> +
> + closemd:
> +
> + gcry_md_close(md);
> +
> + return res;
> }
> #endif
>
I'm going to be offline for a few days, so hopefully someone else on the
list will take over here.
Cheers,
Vito Caputo
More information about the systemd-devel
mailing list