diff options
| author | Mattias Andrée <m@maandree.se> | 2026-05-18 22:57:00 +0200 |
|---|---|---|
| committer | Mattias Andrée <m@maandree.se> | 2026-05-18 22:57:00 +0200 |
| commit | 9607b7c7dd7a368dbdb26322e3609425f63f4a6c (patch) | |
| tree | 2d56e54b6020c9d6844e3c09b1f274d8a0f6ae6e | |
| parent | Checked with sanitizer (diff) | |
| download | sha3sum-1.2.5.tar.gz sha3sum-1.2.5.tar.bz2 sha3sum-1.2.5.tar.xz | |
Signed-off-by: Mattias Andrée <m@maandree.se>
Diffstat (limited to '')
| -rw-r--r-- | common.c | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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; } |
