[hackers] [sbase][PATCH] *sum: support - when using -c

From: Mattias Andrée <maandree_AT_kth.se>
Date: Wed, 23 Mar 2016 19:12:28 +0100

Signed-off-by: Mattias Andrée <maandree_AT_kth.se>
---
 libutil/crypt.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libutil/crypt.c b/libutil/crypt.c
index 0de4269..3f849ba 100644
--- a/libutil/crypt.c
+++ b/libutil/crypt.c
_AT_@ -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);
 	} else {
 		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);
 				ret = 1;
 				continue;
 			}
 			mdchecklist(fp, ops, md, sz, &formatsucks, &noread, &nonmatch);
-			fclose(fp);
+			if (fp != stdin)
+				fclose(fp);
 		}
 	}
 
-- 
2.7.3
Received on Wed Mar 23 2016 - 19:12:28 CET

This archive was generated by hypermail 2.3.0 : Wed Mar 23 2016 - 19:24:13 CET