mirror of
git://git.suckless.org/sbase
synced 2024-12-23 23:43:33 +00:00
crypt: Add some missing error checks for cryptsum
Previously, if a file failed to read in a checksum list, it would be reported as not matched rather than a read failure. Also, if reading from stdin failed, previously a bogus checksum would be printed anyway.
This commit is contained in:
parent
609169d600
commit
52e49329e5
@ -64,7 +64,10 @@ mdchecklist(FILE *listfp, struct crypt_ops *ops, uint8_t *md, size_t sz,
|
||||
(*noread)++;
|
||||
continue;
|
||||
}
|
||||
cryptsum(ops, fp, file, md);
|
||||
if (cryptsum(ops, fp, file, md)) {
|
||||
(*noread)++;
|
||||
continue;
|
||||
}
|
||||
r = mdcheckline(line, md, sz);
|
||||
if (r == 1) {
|
||||
printf("%s: OK\n", file);
|
||||
@ -125,7 +128,9 @@ cryptmain(int argc, char *argv[], struct crypt_ops *ops, uint8_t *md, size_t sz)
|
||||
int ret = 0;
|
||||
|
||||
if (argc == 0) {
|
||||
cryptsum(ops, stdin, "<stdin>", md);
|
||||
if (cryptsum(ops, stdin, "<stdin>", md))
|
||||
ret = 1;
|
||||
else
|
||||
mdprint(md, "<stdin>", sz);
|
||||
} else {
|
||||
for (; *argv; argc--, argv++) {
|
||||
@ -137,11 +142,10 @@ cryptmain(int argc, char *argv[], struct crypt_ops *ops, uint8_t *md, size_t sz)
|
||||
ret = 1;
|
||||
continue;
|
||||
}
|
||||
if (cryptsum(ops, fp, *argv, md)) {
|
||||
if (cryptsum(ops, fp, *argv, md))
|
||||
ret = 1;
|
||||
} else {
|
||||
else
|
||||
mdprint(md, *argv, sz);
|
||||
}
|
||||
if (fp != stdin && fshut(fp, *argv))
|
||||
ret = 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user