HomeFreeBSD

diff: Don't (ab)use sprintf() as a kind of strcat().

Description

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)

Details

Provenance
jhbAuthored on Nov 16 2022, 3:17 AM
Reviewer
bapt
Differential Revision
D36814: diff: Don't (ab)use sprintf() as a kind of strcat().
Parents
rG95a52eb29ca9: diff: Don't treat null characters like carriage returns in readhash().
Branches
Unknown
Tags
Unknown