diff --git a/util/crypt.c b/util/crypt.c index 5787def..1c797a4 100644 --- a/util/crypt.c +++ b/util/crypt.c @@ -10,6 +10,7 @@ cryptmain(int argc, char *argv[], struct crypt_ops *ops, uint8_t *md, size_t sz) { FILE *fp; + int ret = EXIT_SUCCESS; if (argc == 0) { cryptsum(ops, stdin, "", md); @@ -18,15 +19,18 @@ cryptmain(int argc, char *argv[], for (; argc > 0; argc--) { if((fp = fopen(*argv, "r")) == NULL) { weprintf("fopen %s:", *argv); + ret = EXIT_FAILURE; continue; } - cryptsum(ops, fp, *argv, md); - mdprint(md, *argv, sz); + if(cryptsum(ops, fp, *argv, md) == 1) + ret = EXIT_FAILURE; + else + mdprint(md, *argv, sz); fclose(fp); argv++; } } - return EXIT_SUCCESS; + return ret; } int @@ -40,7 +44,7 @@ cryptsum(struct crypt_ops *ops, FILE *fp, const char *f, while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) ops->update(ops->s, buf, n); if (ferror(fp)) { - eprintf("read error: %s:", f); + weprintf("read error: %s:", f); return 1; } ops->sum(ops->s, md);