Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Feb 2024 12:50:52 GMT
From:      Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 5b44edb40583 - main - md5: Ignore files in string and passthrough mode.
Message-ID:  <202402161250.41GCoqB0013823@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=5b44edb4058365ba8e4ccfdb5176c1cddd4394fe

commit 5b44edb4058365ba8e4ccfdb5176c1cddd4394fe
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-02-16 12:37:04 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-02-16 12:37:36 +0000

    md5: Ignore files in string and passthrough mode.
    
    MFC after:      1 week
    Reviewed by:    allanjude, markj
    Differential Revision:  https://reviews.freebsd.org/D43871
---
 sbin/md5/md5.1             | 2 ++
 sbin/md5/md5.c             | 2 +-
 sbin/md5/tests/md5_test.sh | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1
index a17ef5ae30b7..0a8dc46f3b1f 100644
--- a/sbin/md5/md5.1
+++ b/sbin/md5/md5.1
@@ -129,6 +129,7 @@ option, the calculated digest is printed in addition to the exit status being se
 .Pq Note that this option is not yet useful if multiple files are specified.
 .It Fl p , -passthrough
 Echo stdin to stdout and append the checksum to stdout.
+In this mode, any files specified on the command line are silently ignored.
 .It Fl q , -quiet
 Quiet mode \(em only the checksum is printed out.
 Overrides the
@@ -146,6 +147,7 @@ options.
 .It Fl s Ar string , Fl -string= Ns Ar string
 Print a checksum of the given
 .Ar string .
+In this mode, any files specified on the command line are silently ignored.
 .It Fl t , Fl -time-trial
 Run a built-in time trial.
 For the
diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c
index 29f212148ce3..2045b623ff57 100644
--- a/sbin/md5/md5.c
+++ b/sbin/md5/md5.c
@@ -606,7 +606,7 @@ main(int argc, char *argv[])
 		err(1, "Unable to enter capability mode");
 #endif
 
-	if (*argv) {
+	if (*argv && !pflag && string == NULL) {
 		do {
 			const char *filename = *argv;
 			const char *filemode = "rb";
diff --git a/sbin/md5/tests/md5_test.sh b/sbin/md5/tests/md5_test.sh
index 6b00a6b102c4..5b018b18c220 100644
--- a/sbin/md5/tests/md5_test.sh
+++ b/sbin/md5/tests/md5_test.sh
@@ -204,6 +204,8 @@ bsd_${alg}_vec${i}_body() {
 	for opt in -q -qr -rq ; do
 		atf_check -o inline:\"\$out_${i}_${alg}\n\" ${alg} \${opt} in
 	done
+	atf_check -o inline:\"\$inp_${i}\$out_${i}_${alg}\n\" ${alg} -p <in
+	atf_check -o inline:\"\$out_${i}_${alg}\n\" ${alg} -s \"\$inp_${i}\"
 }
 "
 		eval "



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202402161250.41GCoqB0013823>