aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-05-18 22:57:00 +0200
committerMattias Andrée <m@maandree.se>2026-05-18 22:57:00 +0200
commit9607b7c7dd7a368dbdb26322e3609425f63f4a6c (patch)
tree2d56e54b6020c9d6844e3c09b1f274d8a0f6ae6e
parentChecked with sanitizer (diff)
downloadsha3sum-master.tar.gz
sha3sum-master.tar.bz2
sha3sum-master.tar.xz
Keep going in -c mode on error (still exit with value 2)HEAD1.2.5master
Signed-off-by: Mattias Andrée <m@maandree.se>
-rw-r--r--common.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/common.c b/common.c
index 2052553..efaf853 100644
--- a/common.c
+++ b/common.c
@@ -219,12 +219,12 @@ hash(const char *restrict filename, const struct libkeccak_spec *restrict spec,
if (fd < 0) {
if (errno == ENOENT)
return 1;
- eperror();
+ goto error;
}
if ((hex ? generalised_sum_fd_hex : libkeccak_generalised_sum_fd)
(fd, &state, spec, suffix, squeezes > 1 ? NULL : hashsum))
- eperror();
+ goto error;
close(fd);
if (squeezes > 2)
@@ -234,6 +234,10 @@ hash(const char *restrict filename, const struct libkeccak_spec *restrict spec,
libkeccak_state_fast_destroy(&state);
return 0;
+
+error:
+ fprintf(stderr, "%s: %s: %s\n", argv0, filename, strerror(errno));
+ return 2;
}
@@ -254,10 +258,12 @@ check(const struct libkeccak_spec *restrict spec, long int squeezes, const char
int hex, const char *restrict filename, const char *restrict correct_hash)
{
size_t length = (size_t)((spec->output + 7) / 8);
+ int ret;
- if (access(filename, F_OK) || hash(filename, spec, squeezes, suffix, hex)) {
+ ret = hash(filename, spec, squeezes, suffix, hex);
+ if (ret) {
printf("%s: Missing\n", filename);
- return 1;
+ return ret;
}
libkeccak_unhex(hexsum, correct_hash);
@@ -399,7 +405,7 @@ check_checksums(const char *restrict filename, const struct libkeccak_spec *rest
user_error("file is malformated");
free(buf);
- return ret;
+ return ret > 2 ? 2 : ret;
(void) style;
}