From nobody Tue Feb 20 22:05:06 2024 X-Original-To: dev-commits-src-all@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 4TfYNy5mMjz59k9R; Tue, 20 Feb 2024 22:05:06 +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 4TfYNy3G8Zz4sS8; Tue, 20 Feb 2024 22:05:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708466706; 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=V4ZP6t2yu0ClzakuL/lfBZvHhs6OZ1OUmQ8iy1pVYpk=; b=NfVxBLsZcXGH46ekz82Di/e9+4kCj5vHj36dDqxm+Pd0/qanip4peBFFh5PGXqvmE1SXeu vl4UKkUI/SzRywIeZCS/qr3FGtDAqwWFt84sO1ZzLB56bIzS2HLGPPxffugqR2eB8GPP55 mdu+iOhDv23inHSCQmA7vykLfz1yOLO612+kyWa/WpV45+rgsGDFnF+FqmoCw0kIbgQQVE /umGCq5vYej72esF0CmMknfVQevPbvepafbi9fg2xFIgRjHdLnPKA5xhPxi/DIPROQYCXH TM10Mmc/2XVKDfiw+h8bobPeYrwKTze7r3Mzqfwuxzfc75rJMvd5aPv28VC5DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708466706; 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=V4ZP6t2yu0ClzakuL/lfBZvHhs6OZ1OUmQ8iy1pVYpk=; b=rXdrB+l9aysyz4270ym/ASnPY0vW1V0CBBOzcuH0L3uruvsoa+RGkMZsjF72nhsxMWU+PV bRiTn2Oof5I6q9O61Olc2bgRC1cgKxqZkCpl/YekMpdRnXua20up0odAB9+83C6e7zAW6g ftSNi7szFM9IeJCHqZB7DuoQntiNXbVfcKvoPyLwIKdBjQESGcYM6lSZqSyQ/s/ZONEt+0 AdA7GG8yh8WrhvE7Hj/i7/UoW5VRNhTogAmCknlYtxFonUVuLi+2jRRIezr3+TNZJILjZ2 bobU5KtOsfVb0rK3LPvVRmbu5pn6e+6fTFZuOJ78L9dkXVOerrZmVh1NB9sj6g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708466706; a=rsa-sha256; cv=none; b=RyTPS2aRFIox5pFYNAR6TlidVNPoch+pCL4GWtjZzNi/gPaWS4VjQGSzpdlgewzJsPIsDk ouHrA0c5Wn5SyjM4VAHiQg+Tyy0WNLMOPwmZU47vS0VuUKkBfcFF6QespeQccxgQ5muxkR 6Lbgq91sneS7aBzJIUfKlz1PUSYCzEpjwF98vzxk+W1wOCfZoHgurTWWy5CP0D5zXoSErU UrqfR326UQAmAti5NaLkFQRyWZ51wJCeIBAsUQNjxF4jOerJFGmybvcL7eOlAUj5T3oxsh MERs3tWaKwUZWVBbBlIxUbUnCMJdC2896MfZDEin8WJIgRi0bTXSPgH7+9TAEg== 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 4TfYNy1m7Vzc3j; Tue, 20 Feb 2024 22:05:06 +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 41KM565Z063780; Tue, 20 Feb 2024 22:05:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41KM56hn063777; Tue, 20 Feb 2024 22:05:06 GMT (envelope-from git) Date: Tue, 20 Feb 2024 22:05:06 GMT Message-Id: <202402202205.41KM56hn063777@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: c05533d97ac1 - main - md5: Fix GNU check mode. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: c05533d97ac178f8e811407860d47d3c0ae61eed Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=c05533d97ac178f8e811407860d47d3c0ae61eed commit c05533d97ac178f8e811407860d47d3c0ae61eed Author: Dag-Erling Smørgrav AuthorDate: 2024-02-20 22:04:40 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-02-20 22:04:40 +0000 md5: Fix GNU check mode. Fixes: 9b20849bc5f1b500f2de7aeca77f0e6556069bbb MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: imp, allanjude, markj Differential Revision: https://reviews.freebsd.org/D43990 --- sbin/md5/md5.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c index 158769812819..74b61f9bc1ad 100644 --- a/sbin/md5/md5.c +++ b/sbin/md5/md5.c @@ -287,9 +287,10 @@ MD5_Update(MD5_CTX *c, const unsigned char *data, size_t len) } struct chksumrec { - char *filename; - char *chksum; - struct chksumrec *next; + char *filename; + enum input_mode input_mode; + char *chksum; + struct chksumrec *next; }; static struct chksumrec *head = NULL; @@ -362,16 +363,18 @@ gnu_check(const char *checksumsfile) if (rec == NULL) errx(1, "malloc failed"); - if (*filename == '*' || - *filename == ' ' || - *filename == 'U' || - *filename == '^') { - if (lstat(filename, &st) != 0) - filename++; + if ((*filename == '*' || *filename == ' ' || + *filename == 'U' || *filename == '^') && + lstat(filename, &st) != 0 && + lstat(filename + 1, &st) == 0) { + rec->filename = strdup(filename + 1); + rec->input_mode = (enum input_mode)*filename; + } else { + rec->filename = strdup(filename); + rec->input_mode = input_mode; } rec->chksum = strdup(hashstr); - rec->filename = strdup(filename); if (rec->chksum == NULL || rec->filename == NULL) errx(1, "malloc failed"); rec->next = NULL; @@ -612,6 +615,13 @@ main(int argc, char *argv[]) const char *filename = *argv; const char *filemode = "rb"; + if (cflag && mode != mode_bsd) { + input_mode = rec->input_mode; + checkAgainst = rec->chksum; + rec = rec->next; + } + if (input_mode == input_text) + filemode = "r"; if (strcmp(filename, "-") == 0) { f = stdin; } else { @@ -626,14 +636,8 @@ main(int argc, char *argv[]) warn("%s", filename); failed = true; } - if (cflag && mode != mode_bsd) - rec = rec->next; continue; } - if (cflag && mode != mode_bsd) { - checkAgainst = rec->chksum; - rec = rec->next; - } p = MDInput(&Algorithm[digest], f, buf, false); if (f != stdin) (void)fclose(f);