From: Jason Self Date: Tue, 15 Sep 2015 21:59:31 +0000 (-0700) Subject: HashMatch: do return values more strict. X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=ff93bbdae2026ff865e07c05450560d0594d935a;p=skeinsum.git HashMatch: do return values more strict. --- diff --git a/skein_cli.c b/skein_cli.c index c8ae45b..0ab8408 100644 --- a/skein_cli.c +++ b/skein_cli.c @@ -210,6 +210,7 @@ void HashStdin(int tag) } } +/* Return: -1 = Error, 0 = Mismatch, 1 = Match */ int HashMatch(const char StoredDigest[], const char *filename, int quiet) { char mode = 't'; @@ -220,17 +221,19 @@ int HashMatch(const char StoredDigest[], const char *filename, int quiet) char MsgDigest[hashbitlen/2]; if (HashWithMode(filename, MsgDigest, mode) < 0) - return 0; + return -1; if (strcmp(MsgDigest, StoredDigest)) { printf("%s: FAILED\n", filename); return 0; } + if (quiet > 0) printf("%s: OK\n", filename); return 1; } +/* Return: -1 = some errors/mismatches, 1 = all ok */ int VerifyHashesFromFile(FILE *fp, int status, int warn, int quiet) { char hash[PATH_MAX + hashbitlen/4 + 4]; @@ -263,7 +266,7 @@ int VerifyHashesFromFile(FILE *fp, int status, int warn, int quiet) NotProper ++; NoMatch ++; } - else if (!HashMatch(MsgDigest_tmp, file_tmp, quiet)) + else if (HashMatch(MsgDigest_tmp, file_tmp, quiet) <= 0) { NoMatch++; }