tweaks: avoid a warning on newer compilers, by writing an extra byte

When the version number is a trio, the version string will occupy
ten bytes and the terminating NUL byte would not be written (which
was not a problem as byte 12 of the lock data is zero anyway).
But it's better to not have the compiler complain, so allow writing
the terminating NUL byte outside of the ten bytes reserved for the
version string.
This commit is contained in:
Benno Schulenberg 2021-03-03 10:47:41 +01:00
parent bb74aacf2d
commit be9b1a1887

View File

@ -200,7 +200,8 @@ bool write_lockfile(const char *lockfilename, const char *filename, bool modifie
* some byte-order-checking numbers (bytes 1008-1022). */
lockdata[0] = 0x62;
lockdata[1] = 0x30;
snprintf(&lockdata[2], 10, "nano %s", VERSION);
/* It's fine to overwrite byte 12 with the \0 as it is 0x00 anyway. */
snprintf(&lockdata[2], 11, "nano %s", VERSION);
lockdata[24] = mypid % 256;
lockdata[25] = (mypid / 256) % 256;
lockdata[26] = (mypid / (256 * 256)) % 256;