<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/usr.bin/diff, branch release/13.2.0</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=release%2F13.2.0</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=release%2F13.2.0'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2023-01-24T05:12:44Z</updated>
<entry>
<title>diff: Don't (ab)use sprintf() as a kind of strcat().</title>
<updated>2023-01-24T05:12:44Z</updated>
<author>
<name>John Baldwin</name>
<email>jhb@FreeBSD.org</email>
</author>
<published>2022-11-16T03:17:36Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=a8b6a13b0aa3408a7793dad22ad0193a2c32477f'/>
<id>urn:sha1:a8b6a13b0aa3408a7793dad22ad0193a2c32477f</id>
<content type='text'>
Previously print_header() used sprintf() of a buffer to itself as a
kind of string builder but without checking for overflows.  This
raised -Wformat-truncation and -Wrestrict warnings in GCC.  Instead,
just conditionally print the new timestamp fields after the initial
strftime()-formatted string.  While here, use sizeof(buf) with
strftime() rather than a magic number.

Reviewed by:	bapt
Differential Revision:	https://reviews.freebsd.org/D36814

(cherry picked from commit 6100374ccf2644d3fd233bde8b8f4e73d9953c30)
</content>
</entry>
<entry>
<title>diff: Don't treat null characters like carriage returns in readhash().</title>
<updated>2023-01-24T05:12:00Z</updated>
<author>
<name>John Baldwin</name>
<email>jhb@FreeBSD.org</email>
</author>
<published>2022-11-16T03:16:50Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=95a52eb29ca93fb457ac618b8de7a754700e55c4'/>
<id>urn:sha1:95a52eb29ca93fb457ac618b8de7a754700e55c4</id>
<content type='text'>
The implicit fall-through in the !D_FORCEASCII case caused null
characters to be treated as carriage returns honoring the D_STRIPCR,
D_FOLDBLANKS, and D_IGNOREBLANKS flags.

Reported by:	GCC -Wimplicit-fallthrough
Reviewed by:	bapt
Fixes:	 	3cbf98e2bee9 diff: read whole files to determine if they are ASCII text
Differential Revision:	https://reviews.freebsd.org/D36813

(cherry picked from commit 4e0771714d6192119dcf7553b921bf88866d8925)
</content>
</entry>
<entry>
<title>diff: Fix a use after free as well as a memory leak in change().</title>
<updated>2022-11-11T18:18:53Z</updated>
<author>
<name>John Baldwin</name>
<email>jhb@FreeBSD.org</email>
</author>
<published>2022-10-03T23:10:43Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=1f9f319919d7f8b76c8d8a7edb71ca2f39fb40e1'/>
<id>urn:sha1:1f9f319919d7f8b76c8d8a7edb71ca2f39fb40e1</id>
<content type='text'>
When -B or -I are used, change() evaluates the lines in a hunk to
determine if it is a hunk that should be ignored.  It does this by
reading each candidate line into a mallocated buffer via preadline()
and then calling ignoreline().  Previously the buffer was freed as a
side effect of ignoreline_pattern() called from ignoreline().
However, if only -B was specified, then ignoreline_pattern() was not
called and the lines were leaked.  If both options were specified,
then ignoreline_pattern() was called before checking for a blank line
so that the second check was a use after free.

To fix, pull the free() out of ignoreline_pattern() and instead do it
up in change() so that is paired with preadline().

While here, simplify ignoreline() by checking for the -B and -I cases
individually without a separate clause for when both are set.  Also,
do the cheaper check (-B) first, and remove a false comment (this
function is only called if at least one of -I or -B are specified).

Reviewed by:	emaste
Reported by:	GCC 12 -Wuse-after-free
Differential Revision:	https://reviews.freebsd.org/D36822

(cherry picked from commit 3736b2dd327050d2e6c925964b210eccbaac51ab)
</content>
</entry>
<entry>
<title>diff: tests: loosen up requirements for report_identical</title>
<updated>2022-04-21T22:38:00Z</updated>
<author>
<name>Kyle Evans</name>
<email>kevans@FreeBSD.org</email>
</author>
<published>2022-04-19T04:04:13Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=6182c7881829bc1285a93c24a2a77a9543c5b3a9'/>
<id>urn:sha1:6182c7881829bc1285a93c24a2a77a9543c5b3a9</id>
<content type='text'>
This test cannot run without an unprivileged_user being specified
anyways, so just run as the unprivileged user.  Revoking read permisions
works just as well if you're guaranteed non-root.

Reviewed by:	pstef
Sponsored by:	Klara, Inc.

(cherry picked from commit efba49ee5a64f8f56f49e58887484284d785d542)
</content>
</entry>
<entry>
<title>Fix indentation in usr.bin/diff/pr.c</title>
<updated>2022-03-12T18:18:32Z</updated>
<author>
<name>Dimitry Andric</name>
<email>dim@FreeBSD.org</email>
</author>
<published>2022-02-28T20:06:19Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=5e5c14493cba62d7c38c0be7650387a493f61b44'/>
<id>urn:sha1:5e5c14493cba62d7c38c0be7650387a493f61b44</id>
<content type='text'>
In commit 6fa5bf0832ef the pr(1) related code in diff was moved around,
but some part of the indentation was messed up, and one line was
duplicated. Remove the duplicated line, and fix up the indentation.

Reviewed by:	bapt
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D34398

(cherry picked from commit f7d6e97e4bf1fe4c70d5b0ef9fdf649bf07e1c91)
</content>
</entry>
<entry>
<title>diff: read whole files to determine if they are ASCII text</title>
<updated>2021-09-25T08:34:39Z</updated>
<author>
<name>Piotr Pawel Stefaniak</name>
<email>pstef@FreeBSD.org</email>
</author>
<published>2021-08-22T19:57:13Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=bda949b6efdf099846775d3dc595c36561df1cca'/>
<id>urn:sha1:bda949b6efdf099846775d3dc595c36561df1cca</id>
<content type='text'>
Before this change, only the first BUFSIZE bytes were checked.

(cherry picked from commit 3cbf98e2bee91db9ed9118ff557e02cdd449f49a)
</content>
</entry>
<entry>
<title>diff: don't output carriage returns that were stripped on input</title>
<updated>2021-09-25T08:34:38Z</updated>
<author>
<name>Piotr Pawel Stefaniak</name>
<email>pstef@FreeBSD.org</email>
</author>
<published>2021-08-22T16:05:59Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=ece58f7ada409ac68e072cdddcc29e21127aafce'/>
<id>urn:sha1:ece58f7ada409ac68e072cdddcc29e21127aafce</id>
<content type='text'>
--strip-trailing-cr worked as intended for comparison between files,
but the characters were still present in final output.

(cherry picked from commit af2f0164318455433db95adce07af829285b78ad)
</content>
</entry>
<entry>
<title>diff: Use unprivileged_user with report_identical test</title>
<updated>2021-08-22T16:48:55Z</updated>
<author>
<name>Olivier Cochard</name>
<email>olivier@FreeBSD.org</email>
</author>
<published>2021-02-03T16:18:59Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=108633bb1556f1e107b05a68fa0c323ac4d2c712'/>
<id>urn:sha1:108633bb1556f1e107b05a68fa0c323ac4d2c712</id>
<content type='text'>
Approved by:	bapt
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D28466

(cherry picked from commit b67df8d7c203a139b5afbe72e1947fbb8c32dc73)
</content>
</entry>
<entry>
<title>usr.bin/diff: fix UBSan error in readhash</title>
<updated>2021-08-05T08:59:26Z</updated>
<author>
<name>Alex Richardson</name>
<email>arichardson@FreeBSD.org</email>
</author>
<published>2021-07-06T11:16:40Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=7a7324d9cebee6f42d77a39f3a8c657e23676cc2'/>
<id>urn:sha1:7a7324d9cebee6f42d77a39f3a8c657e23676cc2</id>
<content type='text'>
UBSan complains about the `sum = sum * 127 + chrtran(t);` line below since
that can overflow an `int`. Use `unsigned int` instead to ensure that
overflow is well-defined.

Reviewed By:	imp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D31075

(cherry picked from commit c78f449d85e0b292fe5d942cca99f11c1cd430fa)
</content>
</entry>
<entry>
<title>diff: eleminitate useless macros</title>
<updated>2021-05-05T08:37:09Z</updated>
<author>
<name>Baptiste Daroussin</name>
<email>bapt@FreeBSD.org</email>
</author>
<published>2021-01-27T10:47:17Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=7904a2e5a8c56853bd39f5fe22a14cf8b526cd3c'/>
<id>urn:sha1:7904a2e5a8c56853bd39f5fe22a14cf8b526cd3c</id>
<content type='text'>
The diff_output was not bringing any values but was obfuscating
the code.

(cherry picked from commit 7a57c9cb5a4dffb0483beeae6da7cf266ea634be)
</content>
</entry>
</feed>
