From nobody Fri Jun 9 01:39:41 2023 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 4QckKB0yhqz4cJMP; Fri, 9 Jun 2023 01:39:42 +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 4QckKB0WTFz3ttT; Fri, 9 Jun 2023 01:39:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686274782; 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=VXbUXR0Dzq7R7SpZHDyd16dRYjBlMsLEZmOA0h2Dmcg=; b=oDN50w4yv5IS4XMf6VpI3bXXKzy4+4t7Y7Xdicv9eb1/WjNvhl/i9jk3aNmTTCTN/apdiO uxqtR9yJ4ezT4wEitjOiYw9upr7k6jP5LkNQrc+aRDMwQ59b8wld0S0f5Xjwi59UX+xnxF rMKnMZA7eHAluMTex0DDlztRg4PX9hdzNz3DwYhseUHXlbgMGBh8zNeF7z7wqGQZK6crQZ ODNM41OHvw/xGabSHHbXaxhbcQ19iRueZXpGMBg0TgzZkY7BF9CpSW5Vf60BRUoUO3XOdn IDvXLM68gKOOaixy3tVm7xHl08ARHYy6Hlo8sFVzIuINkPujTLugn5zG7eFJ/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1686274782; 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=VXbUXR0Dzq7R7SpZHDyd16dRYjBlMsLEZmOA0h2Dmcg=; b=tb627eRSfgzInohosx9CGTgsH6ljKPB08bCkFrwX8PvOLY3A+vjf4ZoJnAe917s4AW6m48 dXDtabirtNxv9hn4gUCHp02RewViOoumKSZuMg+nliI6F9jLvdqsK/ouBNd9eeXw1x9kpz 5CZfcvadJ086z5LS23iD/h4GiQDeg17Vt2YWapK4hgSN+XOLef0JL9oKpIwWaifVO99hR4 8uLrd553cZLvzdO/j2oD3lq42aiDAejtehHgRTQgHDrA2Lb22N8f1mob4giDreSKXvpQ4W 9rVCtVdGM+/uJWcDLssCciR9KKQ2ZdAVg/N9mFCw+KFyXT6vrLYn8/mHZjdHlQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686274782; a=rsa-sha256; cv=none; b=uYnT0idlR5ZJU/0sZeVsufGabSYP0D30ImXY7ducOVQr2SmXKggEgEqEZEIlDJW+Q48ua2 BG0s7GqFKlX0SeD6L2H+JVPYux3NxdaEKWlaoNgx47A1m6bZrvOtHURFOFHWXeNlrLbscQ lh59Zba4BfXZsLMj5F3bkpxAZXJ2+AiAROy1Md333jyca7IkWqDLut83hF9jrj/eMnCtm5 o/80NfZ0AsxKzOZxD0q5iA7Pxhj3LoQ79Nx+Prc37EQZCH+NJLitLDKewv7v47vkrCcwxh 7pFmZAbb1zid3IL9ppKCdzof9t19Pm79vML+QX9h9+YdxU4PO93JrTR/yolCJw== 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 4QckK96jf0zGXG; Fri, 9 Jun 2023 01:39:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 3591dfRI057136; Fri, 9 Jun 2023 01:39:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3591dfn1057135; Fri, 9 Jun 2023 01:39:41 GMT (envelope-from git) Date: Fri, 9 Jun 2023 01:39:41 GMT Message-Id: <202306090139.3591dfn1057135@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Xin LI Subject: git: d1016568185d - main - hexdump: Partial lines cannot be repetitions of earlier lines. 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: delphij X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d1016568185ddacbf1148acbe26b27258981b4f0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=d1016568185ddacbf1148acbe26b27258981b4f0 commit d1016568185ddacbf1148acbe26b27258981b4f0 Author: Xin LI AuthorDate: 2023-06-09 01:38:47 +0000 Commit: Xin LI CommitDate: 2023-06-09 01:39:05 +0000 hexdump: Partial lines cannot be repetitions of earlier lines. When checking for repetitions of earlier lines, we compare the first nread bytes of the line against the saved line. However, when we read a partial line, it should never be treated as a repetition of an earlier line, even if the first bytes match. This change fixes a bug where a partial line could be incorrectly identified as a repetition of an earlier line. Reported-by: Mark Adler PR: 118723 Reviewed-by: emaste MFC-after: 2 weeks Differential Revision: https://reviews.freebsd.org/D40471 --- usr.bin/hexdump/display.c | 2 +- usr.bin/hexdump/tests/Makefile | 3 +++ usr.bin/hexdump/tests/d_hexdump_UCflag_bug118723.out | 4 ++++ usr.bin/hexdump/tests/d_hexdump_UCvflag_bug118723.out | 4 ++++ usr.bin/hexdump/tests/d_hexdump_bug118723.in | 5 +++++ usr.bin/hexdump/tests/hexdump_test.sh | 8 ++++++++ 6 files changed, 25 insertions(+), 1 deletion(-) diff --git a/usr.bin/hexdump/display.c b/usr.bin/hexdump/display.c index 36306ededfc6..b4e7084e1e97 100644 --- a/usr.bin/hexdump/display.c +++ b/usr.bin/hexdump/display.c @@ -271,7 +271,7 @@ get(void) * XXX bcmp() is not quite right in the presence * of multibyte characters. */ - if (vflag != ALL && + if (need == 0 && vflag != ALL && valid_save && bcmp(curp, savp, nread) == 0) { if (vflag != DUP) { diff --git a/usr.bin/hexdump/tests/Makefile b/usr.bin/hexdump/tests/Makefile index 54863cb05603..f7a3575400bb 100644 --- a/usr.bin/hexdump/tests/Makefile +++ b/usr.bin/hexdump/tests/Makefile @@ -7,6 +7,7 @@ ATF_TESTS_SH= hexdump_test od_test ${PACKAGE}FILES+= d_hexdump_a.in ${PACKAGE}FILES+= d_hexdump_b.in ${PACKAGE}FILES+= d_hexdump_c.in +${PACKAGE}FILES+= d_hexdump_bug118723.in ${PACKAGE}FILES+= d_hexdump_bflag_a.out ${PACKAGE}FILES+= d_hexdump_bflag_b.out ${PACKAGE}FILES+= d_hexdump_bflag_c.out @@ -30,6 +31,8 @@ ${PACKAGE}FILES+= d_hexdump_sflag_a.out ${PACKAGE}FILES+= d_hexdump_UCflag_a.out ${PACKAGE}FILES+= d_hexdump_UCflag_b.out ${PACKAGE}FILES+= d_hexdump_UCflag_c.out +${PACKAGE}FILES+= d_hexdump_UCflag_bug118723.out +${PACKAGE}FILES+= d_hexdump_UCvflag_bug118723.out ${PACKAGE}FILES+= d_hexdump_xflag_a_el.out ${PACKAGE}FILES+= d_hexdump_xflag_b_el.out ${PACKAGE}FILES+= d_hexdump_xflag_c_el.out diff --git a/usr.bin/hexdump/tests/d_hexdump_UCflag_bug118723.out b/usr.bin/hexdump/tests/d_hexdump_UCflag_bug118723.out new file mode 100644 index 000000000000..bd1f5333b6a1 --- /dev/null +++ b/usr.bin/hexdump/tests/d_hexdump_UCflag_bug118723.out @@ -0,0 +1,4 @@ +00000000 61 62 63 64 65 66 67 0a 30 31 32 33 34 35 36 0a |abcdefg.0123456.| +* +00000020 61 62 63 64 65 66 67 0a |abcdefg.| +00000028 diff --git a/usr.bin/hexdump/tests/d_hexdump_UCvflag_bug118723.out b/usr.bin/hexdump/tests/d_hexdump_UCvflag_bug118723.out new file mode 100644 index 000000000000..927897a3cef8 --- /dev/null +++ b/usr.bin/hexdump/tests/d_hexdump_UCvflag_bug118723.out @@ -0,0 +1,4 @@ +00000000 61 62 63 64 65 66 67 0a 30 31 32 33 34 35 36 0a |abcdefg.0123456.| +00000010 61 62 63 64 65 66 67 0a 30 31 32 33 34 35 36 0a |abcdefg.0123456.| +00000020 61 62 63 64 65 66 67 0a |abcdefg.| +00000028 diff --git a/usr.bin/hexdump/tests/d_hexdump_bug118723.in b/usr.bin/hexdump/tests/d_hexdump_bug118723.in new file mode 100644 index 000000000000..8ecef445e1e6 --- /dev/null +++ b/usr.bin/hexdump/tests/d_hexdump_bug118723.in @@ -0,0 +1,5 @@ +abcdefg +0123456 +abcdefg +0123456 +abcdefg diff --git a/usr.bin/hexdump/tests/hexdump_test.sh b/usr.bin/hexdump/tests/hexdump_test.sh index 5e19d1f99225..31ce52b830cd 100755 --- a/usr.bin/hexdump/tests/hexdump_test.sh +++ b/usr.bin/hexdump/tests/hexdump_test.sh @@ -75,6 +75,10 @@ C_flag_body() hexdump -C "$(atf_get_srcdir)/d_hexdump_b.in" atf_check -o file:"$(atf_get_srcdir)/d_hexdump_UCflag_c.out" \ hexdump -C "$(atf_get_srcdir)/d_hexdump_c.in" + atf_check -o file:"$(atf_get_srcdir)/d_hexdump_UCflag_bug118723.out" \ + hexdump -C "$(atf_get_srcdir)/d_hexdump_bug118723.in" + atf_check -o file:"$(atf_get_srcdir)/d_hexdump_UCvflag_bug118723.out" \ + hexdump -Cv "$(atf_get_srcdir)/d_hexdump_bug118723.in" } atf_test_case hd_name @@ -90,6 +94,10 @@ hd_name_body() hd "$(atf_get_srcdir)/d_hexdump_b.in" atf_check -o file:"$(atf_get_srcdir)/d_hexdump_UCflag_c.out" \ hd "$(atf_get_srcdir)/d_hexdump_c.in" + atf_check -o file:"$(atf_get_srcdir)/d_hexdump_UCflag_bug118723.out" \ + hd "$(atf_get_srcdir)/d_hexdump_bug118723.in" + atf_check -o file:"$(atf_get_srcdir)/d_hexdump_UCvflag_bug118723.out" \ + hd -v "$(atf_get_srcdir)/d_hexdump_bug118723.in" } atf_test_case d_flag