From nobody Fri Feb 16 12:50:51 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TbsHH4hWLz5BpKl; Fri, 16 Feb 2024 12:50:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TbsHH27mlz4V9t; Fri, 16 Feb 2024 12:50:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708087851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RPLHWoW1NI0z+VWnLNK7DhJpXrSh4IGpZMEwN21gDJE=; b=v0VNtv9tgRoWiJmf23cPys91oe1cXZf6qQhEwW3+/p6HFsOwXGAQwWb4RvFZFqVFSwZLRb kWGrzl80Lc0KbpbqZnOAAVu4LyToNA4LdNpmd31RuOGemLV1QlwXkFCzwfZjeLFw575fqm 11HlRErlFkP2Wk3SJyGarOsR9JUhxE+dJ8aMQeBvrObfU0XfKs88iaqKUtxyidiPiiOf9R rySs3w129gZTDbGUqcU1UIuoCEU0s/atl21qv4vs1XusLU1c6DrRlPFi+bdkQGh1BuLsCU RW+DyTRla5hdCRsFVoXLr+/ktb4ALZVoABChCLN6X9F563bX63rlDms6bjwFvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708087851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=RPLHWoW1NI0z+VWnLNK7DhJpXrSh4IGpZMEwN21gDJE=; b=uWF+4Qrsihomv6GLncOeDGNa3frgVqd+Eu3THERKWoVxYKL4/JXbXDuQ63le8FTkmWE0EV +76oqsmfcrDDaGea2YBzACMDMf3iEax5vbekItR2oZu4+SiCtnyeYuzauWhNJPAoV+WHTr qZBukiU2KRsZHcmCWpY4itCECFdxbYrlb7Wttp/VYxTgOmv4GcNgFypnGM4qQgq8HNbFZX eSL7ksBgPKSt+59MH5Stz7MNjxAF7yJZqe3rHV6CFwQRSUe9qiThYn1LuKXj5RV/j3XsVM TJgsRWD3Cl097shJIMQNSMI/kVlfAcM4AxJdbvT76TN86Ak9rg1gh+vq4v55Fw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708087851; a=rsa-sha256; cv=none; b=WAKv4jO1A4RQqfouN0cl2rk6dgdNZDu+kbxpyt5SKwRvCHvr/QLpGjYxOAuniMA22aLA/6 esvebkMkVD0FQcm4Uu7hYLgpxJkSC23JLSS77q6IQcTXu6yo8fhxDJ02yt7n8HcmbPSmhm Tw/n7U5XvAj5lNL+sqFeFJ6pJjYhWp+4k+uJzpvPG8eiH//eb2WbNY9qJMajr7dZxO1q5e BUVjZWKBx3SduGSZAZVmigoAPe9NpsDhEsNrqcQd6hiBHj5ifNfcw1S3ddeqm7X0ADEGdk wJw6h7eAjcvxp3uwOMiWtPZ7VslEGmxLEFcPn+gF4HiV6L9XZmnLC9O3n/9pOg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TbsHH1Cp1zPy1; Fri, 16 Feb 2024 12:50:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41GCoplZ013772; Fri, 16 Feb 2024 12:50:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41GCop6T013769; Fri, 16 Feb 2024 12:50:51 GMT (envelope-from git) Date: Fri, 16 Feb 2024 12:50:51 GMT Message-Id: <202402161250.41GCop6T013769@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 72ee91fed4cf - main - md5: Accept "-" as alias for stdin. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 72ee91fed4cfdcfbfb767cc166370b40e50d446a Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=72ee91fed4cfdcfbfb767cc166370b40e50d446a commit 72ee91fed4cfdcfbfb767cc166370b40e50d446a Author: Dag-Erling Smørgrav AuthorDate: 2024-02-16 12:36:58 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-02-16 12:37:29 +0000 md5: Accept "-" as alias for stdin. (based on a patch by jhb) MFC after: 1 week PR: 276915 Reported by: Hannes Hauswedell Reviewed by: allanjude, markj, jhb, emaste Differential Revision: https://reviews.freebsd.org/D43870 --- sbin/md5/md5.1 | 7 ++++++- sbin/md5/md5.c | 12 +++++++++--- sbin/md5/tests/md5_test.sh | 10 ++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/sbin/md5/md5.1 b/sbin/md5/md5.1 index 0cdfff928211..a17ef5ae30b7 100644 --- 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 @@ 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. diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c index c8292fe2f692..29f212148ce3 100644 --- a/sbin/md5/md5.c +++ b/sbin/md5/md5.c @@ -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) { diff --git a/sbin/md5/tests/md5_test.sh b/sbin/md5/tests/md5_test.sh index c6bc1dfd7be0..6b00a6b102c4 100644 --- a/sbin/md5/tests/md5_test.sh +++ b/sbin/md5/tests/md5_test.sh @@ -197,7 +197,9 @@ bsd_${alg}_vec${i}_body() { printf '%s' \"\$inp_${i}\" >in atf_check -o inline:\"\$out_${i}_${alg}\n\" ${alg}