aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2013-07-25 10:33:25 +0200
committerGravatar Christian Hesse <mail@eworm.de>2013-07-25 10:33:25 +0200
commitbe4a7604abed3b0a3ffb85c9ecb5f5bfa63e74fc (patch)
treef93cbb1843e0bff68ae4ca5057f3ae16bcbd6106
parente67a1b95e3388ca2f322fe83816d98b4b61d5092 (diff)
downloadnthash-be4a7604abed3b0a3ffb85c9ecb5f5bfa63e74fc.tar.gz
nthash-be4a7604abed3b0a3ffb85c9ecb5f5bfa63e74fc.tar.zst
reintroduce warning about line breaks
-rw-r--r--nthash.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/nthash.c b/nthash.c
index ac3922a..6cd069b 100644
--- a/nthash.c
+++ b/nthash.c
@@ -10,6 +10,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <iconv.h>
#include <nettle/md4.h>
@@ -23,7 +24,7 @@ int main(int argc, char **argv) {
char buffer[BUF_SIZE], buffernull[2 * BUF_SIZE];
char *in = buffer, *out = buffernull;
uint8_t digest[MD4_DIGEST_SIZE];
- int i;
+ int i, linebreak = 0;
size_t done, inbytes, outbytes;
iconv_t conv;
@@ -32,6 +33,9 @@ int main(int argc, char **argv) {
done = inbytes = fread(buffer, 1, BUF_SIZE, stdin);
outbytes = 2 * inbytes;
+ if (strstr(buffer, "\n") != NULL)
+ linebreak++;
+
conv = iconv_open(TOCODE, FROMCODE);
iconv(conv, &in, &inbytes, &out, &outbytes);
iconv_close(conv);
@@ -43,6 +47,9 @@ int main(int argc, char **argv) {
if (ferror(stdin))
return EXIT_FAILURE;
+ if (linebreak)
+ fprintf(stderr, "Warning: Input contains line break!\n");
+
md4_digest(&ctx, MD4_DIGEST_SIZE, digest);
for (i = 0; i < MD4_DIGEST_SIZE; i++)