Page MenuHomeFreeBSD

D43870.diff
No OneTemporary

D43870.diff

diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1
--- a/sbin/md5/md5.1
+++ b/sbin/md5/md5.1
@@ -1,4 +1,4 @@
-.Dd May 10, 2023
+.Dd February 13, 2024
.Dt MD5 1
.Os
.Sh NAME
@@ -79,6 +79,11 @@
format that match those of the similarly named utility that ships with
Perl.
.Pp
+In all cases, each file listed on the command line is processed separately.
+If no files are listed on the command line, or a file name is given as
+.Pa - ,
+input is taken from stdin instead.
+.Pp
It is conjectured that it is computationally infeasible to
produce two messages having the same message digest, or to produce any
message having a given prespecified target message digest.
diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c
--- a/sbin/md5/md5.c
+++ b/sbin/md5/md5.c
@@ -611,11 +611,16 @@
const char *filename = *argv;
const char *filemode = "rb";
+ if (strcmp(filename, "-") == 0) {
+ f = stdin;
+ } else {
#ifdef HAVE_CAPSICUM
- if ((f = fileargs_fopen(fa, filename, filemode)) == NULL) {
+ f = fileargs_fopen(fa, filename, filemode);
#else
- if ((f = fopen(filename, filemode)) == NULL) {
+ f = fopen(filename, filemode);
#endif
+ }
+ if (f == NULL) {
if (errno != ENOENT || !(cflag && ignoreMissing)) {
warn("%s", filename);
failed = true;
@@ -633,7 +638,8 @@
rec = rec->next;
}
p = MDInput(&Algorithm[digest], f, buf, false);
- (void)fclose(f);
+ if (f != stdin)
+ (void)fclose(f);
MDOutput(&Algorithm[digest], p, filename);
} while (*++argv);
} else if (!cflag && string == NULL && !skip) {
diff --git a/sbin/md5/tests/md5_test.sh b/sbin/md5/tests/md5_test.sh
--- a/sbin/md5/tests/md5_test.sh
+++ b/sbin/md5/tests/md5_test.sh
@@ -197,7 +197,9 @@
printf '%s' \"\$inp_${i}\" >in
atf_check -o inline:\"\$out_${i}_${alg}\n\" ${alg} <in
atf_check -o inline:\"\$name_bsd_${alg} (in) = \$out_${i}_${alg}\n\" ${alg} in
+ atf_check -o inline:\"\$name_bsd_${alg} (-) = \$out_${i}_${alg}\n\" ${alg} - <in
atf_check -o inline:\"\$out_${i}_${alg} in\n\" ${alg} -r in
+ atf_check -o inline:\"\$out_${i}_${alg} -\n\" ${alg} -r - <in
# -q overrides -r regardless of order
for opt in -q -qr -rq ; do
atf_check -o inline:\"\$out_${i}_${alg}\n\" ${alg} \${opt} in
@@ -215,9 +217,13 @@
atf_check -o inline:\"\$out_${i}_${alg} -\n\" ${alg}sum <in
atf_check -o inline:\"\$out_${i}_${alg} *-\n\" ${alg}sum -b <in
atf_check -o inline:\"\$out_${i}_${alg} in\n\" ${alg}sum in
+ atf_check -o inline:\"\$out_${i}_${alg} -\n\" ${alg}sum - <in
atf_check -o inline:\"\$out_${i}_${alg} *in\n\" ${alg}sum -b in
+ atf_check -o inline:\"\$out_${i}_${alg} *-\n\" ${alg}sum -b - <in
atf_check -o inline:\"\$name_bsd_${alg} (in) = \$out_${i}_${alg}\n\" ${alg}sum --tag in
+ atf_check -o inline:\"\$name_bsd_${alg} (-) = \$out_${i}_${alg}\n\" ${alg}sum --tag - <in
atf_check -o inline:\"\$out_${i}_${alg} in\0\" ${alg}sum -z in
+ atf_check -o inline:\"\$out_${i}_${alg} -\0\" ${alg}sum -z - <in
}
"
eval "
@@ -233,9 +239,13 @@
atf_check -o inline:\"\$out_${i}_${alg} *-\n\" shasum \$alg_perl_${alg} -b <in
atf_check -o inline:\"\$out_${i}_${alg} U-\n\" shasum \$alg_perl_${alg} -U <in
atf_check -o inline:\"\$out_${i}_${alg} in\n\" shasum \$alg_perl_${alg} in
+ atf_check -o inline:\"\$out_${i}_${alg} -\n\" shasum \$alg_perl_${alg} - <in
atf_check -o inline:\"\$out_${i}_${alg} *in\n\" shasum \$alg_perl_${alg} -b in
+ atf_check -o inline:\"\$out_${i}_${alg} *-\n\" shasum \$alg_perl_${alg} -b - <in
atf_check -o inline:\"\$out_${i}_${alg} Uin\n\" shasum \$alg_perl_${alg} -U in
+ atf_check -o inline:\"\$out_${i}_${alg} U-\n\" shasum \$alg_perl_${alg} -U - <in
atf_check -o inline:\"\$name_perl_${alg} (in) = \$out_${i}_${alg}\n\" shasum \$alg_perl_${alg} --tag in
+ atf_check -o inline:\"\$name_perl_${alg} (-) = \$out_${i}_${alg}\n\" shasum \$alg_perl_${alg} --tag - <in
}
"
done

File Metadata

Mime Type
text/plain
Expires
Sun, Apr 27, 12:54 PM (17 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17817849
Default Alt Text
D43870.diff (3 KB)

Event Timeline