]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
diff: Don't (ab)use sprintf() as a kind of strcat().
authorJohn Baldwin <jhb@FreeBSD.org>
Wed, 16 Nov 2022 03:17:36 +0000 (19:17 -0800)
committerJohn Baldwin <jhb@FreeBSD.org>
Tue, 24 Jan 2023 05:12:44 +0000 (21:12 -0800)
commita8b6a13b0aa3408a7793dad22ad0193a2c32477f
tree9707e20e397cb436b34b9588e33a72288778bc05
parent95a52eb29ca93fb457ac618b8de7a754700e55c4
diff: Don't (ab)use sprintf() as a kind of strcat().

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)
usr.bin/diff/diffreg.c