diff options
author | Stefan Eßer <se@FreeBSD.org> | 2022-07-26 21:04:57 +0000 |
---|---|---|
committer | Stefan Eßer <se@FreeBSD.org> | 2022-07-26 21:04:57 +0000 |
commit | 9f3aa538e307743b2b5048d38f87b7fd32d0c596 (patch) | |
tree | bab67dbd822a326f202ef5fb3c52d3eac2914702 /sbin/md5/md5.c | |
parent | 08604a023dc1b601289b7de20509462a3a3ed6ad (diff) | |
download | src-9f3aa538e307743b2b5048d38f87b7fd32d0c596.tar.gz src-9f3aa538e307743b2b5048d38f87b7fd32d0c596.zip |
sbin/md5.c: fix -q -c for BSD style versions
The BSD style commands (with names not ending in "sum") ignored the -c
options and the passed digest value when invoked with -q.
The man page stated that -q causes only the calculated digest to be
printed, but did not consider the case of both the -q and -c being
used in combination.
Since there is no warning that -c will be ignored when the -q option
is used, users night (and did) expect that the exit code would reflect
the matching of the calculated digest and the argument passed with -c.
This update implements and documents this expected behavior.
PR: 265461
Reported by: Dmitrij <bugs.freebsd@1fff.net>
MFC after: 2 weeks
Diffstat (limited to 'sbin/md5/md5.c')
-rw-r--r-- | sbin/md5/md5.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c index 7235e6e0a39f..97c587efd63c 100644 --- a/sbin/md5/md5.c +++ b/sbin/md5/md5.c @@ -436,6 +436,8 @@ MDOutput(const Algorithm_t *alg, char *p, char *argv[]) printf("%s: %s\n", *argv, checkfailed ? "FAILED" : "OK"); } else if (qflag || argv == NULL) { printf("%s\n", p); + if (cflag) + checkfailed = strcasecmp(checkAgainst, p) != 0; } else { if (rflag) if (gnu_emu) |