From nobody Tue Feb 10 15:27:34 2026 X-Original-To: dev-commits-src-branches@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 4f9QRc27Zmz6RVQt for ; Tue, 10 Feb 2026 15:27:40 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4f9QRc06qKz46cV for ; Tue, 10 Feb 2026 15:27:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770737260; 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=DrWt8bLy1o1oNFHvv19E2EDNiPJ6aW8EAslWMvwP1OU=; b=yRmAWVsXPIsIphGPTP/01k941n1zjUMoMkPUG9FYVHMaTB9GB0/fd/sDM7FozFwkpAKeaS gmv2VznnSInhs6IRLiInmMbuG06uvY29Tno7MI0dRpFOJ+p9l3IwZDQ9ZUCIn2+aCNzdWD Tt6INJg5zikE+88zFxrlV4vBxNmEWE7gqY8EnzaCwDtDG+VxAdGp4IddbQQk8SaFP2/smL KH2BeaMXl495jbstgiazEos8o3dE29J3Itv5LXboEJZG1DF/bFG1lNWZxbdtIFSJysx2PH mvpi/EZBcVmtvJjHio2RN+VTYobpZJB8xVvj6BS0kzX0c5ST/+UpQim5AhHLBg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1770737260; a=rsa-sha256; cv=none; b=V0CsNCNn49dN2PSISxCX6s86kwafPc2HKEGjrJ356lk7SVjfn62jYHNQjBo0bREfoBt14S Uml9i5jWPtBdKK1BSZ+GoowBVEzpiAk2jX+NpeLNXvkYjEYp7kfctlXZCkin97em56fC1k UUxk52jij9oBaIvBxuWM6jaIBlVv65GjldNhXD/FFd1N6vjIGyoY5s6Mx/25BVEiYOiLR8 /G9TI2HPux90Rx3V9tuNL9m/UuFEwwgJyXtRCNDCXqow5nMBRs82H61sOMm3JkWx2tSFhm HxfQL/CXJAyLud8MT0Q183xvSZkzT7Bn4KfOz2jOI/0hjncW4BK4wOfd+t9D+A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770737260; 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=DrWt8bLy1o1oNFHvv19E2EDNiPJ6aW8EAslWMvwP1OU=; b=KUqGdnyeVmarVlzG+WY6fi9TqjpdE+IXBMcmSmmFP1csVORhfzuw1ldzaDLepUvlKqwyP5 Nio0yXrmV6iM7g2Za5bkKzulzpJwImEF/zrGuiyg/Gyc2sgrHrxGT9LdoqK16vGQtq5kZM Xk2ookZkV6KNxJQVrztJrOjcrgyapGJsYNy0lVgcIedqlyqC3i3qB2PlCHos1+wUgdIVEE MYk76p61iS+saUxx3s166o8zLkJBQ/9dA8AA5/4433VVwwwSV28fuljtERsBIHqBVDTZLB 4q7La3r7f79YBV7tGTj2+x/RZKJEkLTSMv83Hd4T237qsNjus2QNDbZ1cGWW5Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f9QRb5jL5z1NRN for ; Tue, 10 Feb 2026 15:27:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 451d8 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 10 Feb 2026 15:27:34 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: b97396baca2b - stable/15 - libdiff: Simplify truncation detection List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@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/stable/15 X-Git-Reftype: branch X-Git-Commit: b97396baca2bff80ba68e1e69dbf9a6ab44e1539 Auto-Submitted: auto-generated Date: Tue, 10 Feb 2026 15:27:34 +0000 Message-Id: <698b4e66.451d8.4859031b@gitrepo.freebsd.org> The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=b97396baca2bff80ba68e1e69dbf9a6ab44e1539 commit b97396baca2bff80ba68e1e69dbf9a6ab44e1539 Author: Dag-Erling Smørgrav AuthorDate: 2026-02-05 14:39:34 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-02-10 14:24:07 +0000 libdiff: Simplify truncation detection * Adjust the comment to reflect the fact that SIGBUS can occur not only if the file is truncated, but also if an I/O error occurs while paging in any part of it. * Instead of setting a flag, just return EIO. * Adjust the unit test accordingly. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: thj, kevans Differential Revision: https://reviews.freebsd.org/D55108 (cherry picked from commit a689bfa4e25af8307709dc12f75b0e02a65abf18) --- contrib/libdiff/include/diff_main.h | 1 - contrib/libdiff/lib/diff_atomize_text.c | 12 +++++++----- lib/libdiff/tests/libdiff_test.c | 3 +-- usr.bin/diff/diffreg_new.c | 4 ---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/contrib/libdiff/include/diff_main.h b/contrib/libdiff/include/diff_main.h index 11700580db4b..04a6c6e748c9 100644 --- a/contrib/libdiff/include/diff_main.h +++ b/contrib/libdiff/include/diff_main.h @@ -118,7 +118,6 @@ struct diff_data { /* Flags set by file atomizer. */ #define DIFF_ATOMIZER_FOUND_BINARY_DATA 0x00000001 -#define DIFF_ATOMIZER_FILE_TRUNCATED 0x00000002 /* Flags set by caller of diff_main(). */ #define DIFF_FLAG_IGNORE_WHITESPACE 0x00000001 diff --git a/contrib/libdiff/lib/diff_atomize_text.c b/contrib/libdiff/lib/diff_atomize_text.c index d8a69733fc00..9ed611cce4b2 100644 --- a/contrib/libdiff/lib/diff_atomize_text.c +++ b/contrib/libdiff/lib/diff_atomize_text.c @@ -141,6 +141,7 @@ diff_data_atomize_text_lines_mmap(struct diff_data *d) bool embedded_nul = false; unsigned int array_size_estimate = d->len / 50; unsigned int pow2 = 1; + int ret = DIFF_RC_OK; while (array_size_estimate >>= 1) pow2++; @@ -152,13 +153,14 @@ diff_data_atomize_text_lines_mmap(struct diff_data *d) sigaction(SIGBUS, &act, &oact); if (sigsetjmp(diff_data_signal_env, 0) > 0) { /* - * The file was truncated while we were reading it. Set - * the end pointer to the beginning of the line we were - * trying to read, adjust the file length, and set a flag. + * The file was truncated while we were reading it, or an + * I/O error occurred. Set the end pointer to the + * beginning of the line we were trying to read, adjust + * the file length, and set the return value to an error. */ end = pos; d->len = end - d->data; - d->atomizer_flags |= DIFF_ATOMIZER_FILE_TRUNCATED; + ret = EIO; } while (pos < end) { const uint8_t *line_start = pos, *line_end = pos; @@ -203,7 +205,7 @@ diff_data_atomize_text_lines_mmap(struct diff_data *d) if (embedded_nul) d->atomizer_flags |= DIFF_ATOMIZER_FOUND_BINARY_DATA; - return DIFF_RC_OK; + return ret; } static int diff --git a/lib/libdiff/tests/libdiff_test.c b/lib/libdiff/tests/libdiff_test.c index e82a36f3d38a..2a7c1b37e2c2 100644 --- a/lib/libdiff/tests/libdiff_test.c +++ b/lib/libdiff/tests/libdiff_test.c @@ -45,10 +45,9 @@ ATF_TC_BODY(diff_atomize_truncated, tc) rewind(f); ATF_REQUIRE(truncate(fn, size / 2) == 0); ATF_REQUIRE((p = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fileno(f), 0)) != MAP_FAILED); - ATF_REQUIRE(diff_atomize_file(&d, &cfg, f, p, size, 0) == 0); + ATF_REQUIRE(diff_atomize_file(&d, &cfg, f, p, size, 0) == EIO); ATF_REQUIRE((size_t)d.len <= size / 2); ATF_REQUIRE((size_t)d.len >= size / 2 - sizeof(line)); - ATF_REQUIRE(d.atomizer_flags & DIFF_ATOMIZER_FILE_TRUNCATED); } ATF_TC_CLEANUP(diff_atomize_truncated, tc) { diff --git a/usr.bin/diff/diffreg_new.c b/usr.bin/diff/diffreg_new.c index d932764bb6da..f29e4ad8b9ed 100644 --- a/usr.bin/diff/diffreg_new.c +++ b/usr.bin/diff/diffreg_new.c @@ -223,14 +223,10 @@ diffreg_new(char *file1, char *file2, int flags, int capsicum) rc = D_ERROR; goto done; } - if (left.atomizer_flags & DIFF_ATOMIZER_FILE_TRUNCATED) - warnx("%s truncated", file1); if (diff_atomize_file(&right, cfg, f2, (uint8_t *)str2, st2.st_size, diff_flags)) { rc = D_ERROR; goto done; } - if (right.atomizer_flags & DIFF_ATOMIZER_FILE_TRUNCATED) - warnx("%s truncated", file2); result = diff_main(cfg, &left, &right); if (result->rc != DIFF_RC_OK) {