nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit be9b1a188737c3cf5b08b875f2e4153ee5a47446
parent bb74aacf2d4ec4417b09f2dca4eb8a75e5c333c8
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed,  3 Mar 2021 10:47:41 +0100

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.

Diffstat:
Msrc/files.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/files.c b/src/files.c @@ -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;