aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-11-14 10:04:35 +0100
committerMattias Andrée <maandree@operamail.com>2014-11-14 10:04:35 +0100
commit4ab227c89a483dc2ff51a1a57f88239e20e64fa4 (patch)
tree8fb6c1050fd629372d883cac124564f94d324df5 /src
parentderp (diff)
downloadsha3sum-4ab227c89a483dc2ff51a1a57f88239e20e64fa4.tar.gz
sha3sum-4ab227c89a483dc2ff51a1a57f88239e20e64fa4.tar.bz2
sha3sum-4ab227c89a483dc2ff51a1a57f88239e20e64fa4.tar.xz
m
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rw-r--r--src/common.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/common.c b/src/common.c
index e9bdaf2..051e32f 100644
--- a/src/common.c
+++ b/src/common.c
@@ -335,7 +335,7 @@ static int check_checksums(const char* restrict filename, const libkeccak_spec_t
}
size = ptr;
close(fd), fd = -1;
-
+
if (ptr == size)
{
if (new = realloc(buf, size += 1), new == NULL)
@@ -354,15 +354,19 @@ static int check_checksums(const char* restrict filename, const libkeccak_spec_t
else if (('A' <= c) && (c <= 'F'));
else if ((c == ' ') || (c == '\t'))
hash_end = ptr, stage++;
+ else if ((c == '\n') || (c == '\f') || (c == '\r'))
+ hash_end = ptr, stage = 3;
else
{
- rc = USER_ERROR("file is malformated");
+ rc = USER_ERROR("file is malformated"); /* FIXME error at end of file! c is zero! why!? */
goto fail;
}
}
else if (stage == 1)
{
- if ((c != ' ') && (c != '\t'))
+ if ((c == '\n') || (c == '\f') || (c == '\r'))
+ stage = 3;
+ else if ((c != ' ') && (c != '\t'))
file_start = ptr, stage++;
}
else if (stage == 2)