<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/usr.bin/diff/diffreg.c, branch releng/13.5</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src/atom?h=releng%2F13.5</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src/atom?h=releng%2F13.5'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/'/>
<updated>2024-08-01T16:46:19Z</updated>
<entry>
<title>diff: Fix integer overflow.</title>
<updated>2024-08-01T16:46:19Z</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2024-07-29T14:02:29Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=c14665b4aee7e1594467bac4a9d9cc5c66173975'/>
<id>urn:sha1:c14665b4aee7e1594467bac4a9d9cc5c66173975</id>
<content type='text'>
The legacy Stone algorithm uses `int` to represent line numbers, array
indices, and array lengths.  If given inputs approaching `INT_MAX` lines,
it would overflow and attempt to allocate ridiculously large amounts of
memory.  To avoid this without penalizing non-pathological inputs,
switch a few variables to `size_t` and add checks while and immediately
after reading both inputs.

MFC after:	3 days
PR:		280371
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D46169

(cherry picked from commit 9317242469f1ca682626d9806f8caf65d143c09a)
</content>
</entry>
<entry>
<title>diff: honour -B flag with -q</title>
<updated>2024-06-07T21:15:57Z</updated>
<author>
<name>Ed Maste</name>
<email>emaste@FreeBSD.org</email>
</author>
<published>2024-05-16T14:53:23Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=12ea2d04c37982cabf7865e8897226c81aae4ab0'/>
<id>urn:sha1:12ea2d04c37982cabf7865e8897226c81aae4ab0</id>
<content type='text'>
PR:		278988
Reviewed by:	bapt
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45220

(cherry picked from commit fb623aab3927a6825ff7731198ec2e33426f7607)
(cherry picked from commit 1b7672ed992963e1c79ccc152f4afd72c91481f3)
</content>
</entry>
<entry>
<title>Remove $FreeBSD$: one-line .c pattern</title>
<updated>2023-08-23T17:43:26Z</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2023-08-22T01:31:41Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src/commit/?id=3d497e17ebd33fe0f58d773e35ab994d750258d6'/>
<id>urn:sha1:3d497e17ebd33fe0f58d773e35ab994d750258d6</id>
<content type='text'>
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/

Similar commit in main:
(cherry picked from commit 1d386b48a555)
</content>
</entry>
<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: 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>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>
