From 735e6a601dbb851cdc110480202232c0dede2291 Mon Sep 17 00:00:00 2001 From: Klaus Alexander Seistrup Date: Sun, 9 Feb 2014 08:42:40 +0100 Subject: Update sha3sum.c The code in sha3sum.c didn't put a `'\0'` char at the end of the `out` buffer, and the binary equivalent of the hexdigest was output to the terminal. This patch seems to remedy the case and fixes #10. --- c/sha3sum.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/c/sha3sum.c b/c/sha3sum.c index 87480ea..c955d52 100644 --- a/c/sha3sum.c +++ b/c/sha3sum.c @@ -646,6 +646,7 @@ int main(int argc, char** argv) *(out + outptr++) = HEXADECA[(v >> 4) & 15]; *(out + outptr++) = HEXADECA[v & 15]; } + out[outptr] = '\0'; printf("%s %s\n", out, filename ? filename : "-"); } } @@ -662,6 +663,7 @@ int main(int argc, char** argv) out[b * 2 ] = HEXADECA[(v >> 4) & 15]; out[b * 2 + 1] = HEXADECA[v & 15]; } + out[b*2] = '\0'; printf("%s %s\n", out, filename ? filename : "-"); } for (_ = 1; _ < i; _++) @@ -685,6 +687,7 @@ int main(int argc, char** argv) out[b * 2 ] = HEXADECA[(v >> 4) & 15]; out[b * 2 + 1] = HEXADECA[v & 15]; } + out[b*2] = '\0'; printf("%s\n", out); } } -- cgit v1.2.3-70-g09d2