aboutsummaryrefslogtreecommitdiffstats
path: root/c/sha3sum.c
diff options
context:
space:
mode:
authorKlaus Alexander Seistrup <kseistrup@users.noreply.github.com>2014-02-09 08:42:40 +0100
committerKlaus Alexander Seistrup <kseistrup@users.noreply.github.com>2014-02-09 08:42:40 +0100
commit735e6a601dbb851cdc110480202232c0dede2291 (patch)
treec1e3238e10d7d91cfcbef3eeb4f743aecadefac7 /c/sha3sum.c
parentmisc (diff)
downloadsha3sum-735e6a601dbb851cdc110480202232c0dede2291.tar.gz
sha3sum-735e6a601dbb851cdc110480202232c0dede2291.tar.bz2
sha3sum-735e6a601dbb851cdc110480202232c0dede2291.tar.xz
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.
Diffstat (limited to '')
-rw-r--r--c/sha3sum.c3
1 files changed, 3 insertions, 0 deletions
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);
}
}