nano

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

commit 9f4b4c975a5425eaabcc6e10e432d86a3d26fb83
parent 0293eac1d1747b45c8e1e20d9c6b7e27a5e272ca
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Sat,  4 Jun 2016 09:30:41 +0200

files: prevent dereferencing a possible (although very unlikely) NULL

Don't catch the NULL earlier, because we do want an error message when
opening the lockfile fails.

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

diff --git a/src/files.c b/src/files.c @@ -252,7 +252,8 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi snprintf(&lockdata[2], 11, "nano %s", VERSION); strncpy(&lockdata[28], mypwuid->pw_name, 16); strncpy(&lockdata[68], myhostname, 31); - strncpy(&lockdata[108], origfilename, 768); + if (origfilename != NULL) + strncpy(&lockdata[108], origfilename, 768); if (modified == TRUE) lockdata[1007] = 0x55;