mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-21 18:27:22 +00:00
md5: Accept "-" as alias for stdin.
(based on a patch by jhb) MFC after: 1 week PR: 276915 Reported by: Hannes Hauswedell <h2+fbsdports@fsfe.org> Reviewed by: allanjude, markj, jhb, emaste Differential Revision: https://reviews.freebsd.org/D43870
This commit is contained in:
parent
e00fd24262
commit
72ee91fed4
|
@ -1,4 +1,4 @@
|
|||
.Dd May 10, 2023
|
||||
.Dd February 13, 2024
|
||||
.Dt MD5 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -79,6 +79,11 @@ utility does the same, but with command-line options and an output
|
|||
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.
|
||||
|
|
|
@ -611,11 +611,16 @@ main(int argc, char *argv[])
|
|||
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 @@ main(int argc, char *argv[])
|
|||
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) {
|
||||
|
|
|
@ -197,7 +197,9 @@ bsd_${alg}_vec${i}_body() {
|
|||
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 @@ gnu_${alg}_vec${i}_body() {
|
|||
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 @@ perl_${alg}_vec${i}_body() {
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue