crypt: error status code if an error occured in a file series
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
This commit is contained in:
parent
7727530b53
commit
18b6e40161
10
util/crypt.c
10
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, "<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);
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user