GCC 13 complains that we might be writing too much to an on-stack buffer
when createing a filename with the following warnings:
tftpd.c: In function 'validate_access':
tftpd.c:643:40: warning: '.' directive
writing 1 byte into a region of size between 0 and 1023 [-Wformat-overflow=]
643 | sprintf(newname, "%s.%s.%02d", filename, yyyymmdd, i); | ^
In function 'find_next_name',
inlined from 'validate_access' at
tftpd.c:762:13:
tftpd.c:643:34: note: directive argument in the range [0, 99]
643 | sprintf(newname, "%s.%s.%02d", filename, yyyymmdd, i); | ^~~~~~~~~~~~
tftpd.c:643:17: note: 'sprintf' output 5 or more bytes (assuming 1028) into a destination of size 1024
643 | sprintf(newname, "%s.%s.%02d", filename, yyyymmdd, i); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In practice there is a check that filename isn't too long given the
time format and other static characters so GCC is incorrect, but GCC
isn't wrong that we're potentially trying to put a MAXPATHLEN length
string + some other characters into a MAXPATHLEN buffer (if you ignore
the check GCC can't realistically evaluate at compile time).
Switch to snprintf to populate filename to ensure that future logic
errors don't result in a stack overflow.
Shorten the questionably named yyyymmdd buffer enough to slience the
warning (checking the snprintf return value isn't sufficent) while
preserving maximum flexibility for admins who use the -F option.
Use a define in place of the magic 5.