From 8d1d5d6de8cc9b66c318d2676b42a87e8f32ec96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Tue, 25 Jun 2013 13:07:02 +0200 Subject: [PATCH] nettle-hash.c: Use stack allocation for the small hex output buffer. --- ChangeLog | 3 +++ tools/nettle-hash.c | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f9fc780..d6327ab7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2013-06-25 Niels Möller <nisse@lysator.liu.se> + * tools/nettle-hash.c (digest_file): Use stack allocation for the + small hex output buffer. + * examples/io.c (MIN): Deleted unused macro. 2013-05-21 Niels Möller <nisse@lysator.liu.se> diff --git a/tools/nettle-hash.c b/tools/nettle-hash.c index 5710216e..b4759690 100644 --- a/tools/nettle-hash.c +++ b/tools/nettle-hash.c @@ -108,7 +108,7 @@ digest_file(const struct nettle_hash *alg, else { unsigned i; - char *hex = xalloc(BASE16_ENCODE_LENGTH(8) + 1); + char hex[BASE16_ENCODE_LENGTH(8) + 1]; for (i = 0; i + 8 < digest_length; i += 8) { base16_encode_update(hex, 8, digest + i); @@ -118,7 +118,6 @@ digest_file(const struct nettle_hash *alg, base16_encode_update(hex, digest_length - i, digest + i); hex[BASE16_ENCODE_LENGTH(digest_length - i)] = 0; printf("%s %s\n", hex, alg->name); - free(hex); } free(digest); -- GitLab