nano

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

commit 325d774393a1bb001b2f0da6d960b400f5784754
parent 0856f53703318e103c0f7654ff617e3c568dedb0
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu,  6 Feb 2020 16:00:48 +0100

locking: accept a minimal amount of data, enough for PID plus username

Maybe reading from a remote filesystem happens in small chunks;
don't call foul when the first chunk contains all we need.

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

diff --git a/src/files.c b/src/files.c @@ -289,7 +289,9 @@ int do_lockfile(const char *filename, bool ask_the_user) close(lockfd); - if (readamt < LOCKSIZE || lockbuf[0] != 0x62 || lockbuf[1] != 0x30) { + /* If not enough data has been read to show the needed things, + * or the two magic bytes are not there, skip the lock file. */ + if (readamt < 68 || lockbuf[0] != 0x62 || lockbuf[1] != 0x30) { statusline(ALERT, _("Bad lock file is ignored: %s"), lockfilename); free(lockbuf); goto free_the_name;