*sum: support - when using -c

Signed-off-by: Mattias Andrée <maandree@kth.se>
This commit is contained in:
Mattias Andrée 2016-03-23 19:12:28 +01:00 committed by sin
parent 75611997f9
commit 44a6d65832

View File

@ -89,13 +89,16 @@ cryptcheck(int argc, char *argv[], struct crypt_ops *ops, uint8_t *md, size_t sz
mdchecklist(stdin, ops, md, sz, &formatsucks, &noread, &nonmatch); mdchecklist(stdin, ops, md, sz, &formatsucks, &noread, &nonmatch);
} else { } else {
for (; *argv; argc--, argv++) { for (; *argv; argc--, argv++) {
if (!(fp = fopen(*argv, "r"))) { if ((*argv)[0] == '-' && !(*argv)[1]) {
fp = stdin;
} else if (!(fp = fopen(*argv, "r"))) {
weprintf("fopen %s:", *argv); weprintf("fopen %s:", *argv);
ret = 1; ret = 1;
continue; continue;
} }
mdchecklist(fp, ops, md, sz, &formatsucks, &noread, &nonmatch); mdchecklist(fp, ops, md, sz, &formatsucks, &noread, &nonmatch);
fclose(fp); if (fp != stdin)
fclose(fp);
} }
} }