From ad9351c8ade5f86afe44a01fc5677bd7f10627cd Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Sun, 15 Nov 2015 07:06:08 +0000 Subject: [PATCH] Backport r5391 from trunk. git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_2_4_branch@5421 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/files.c | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 861722e9..e9023467 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-11-06 Benno Schulenberg + * src/files.c (write_lockfile): Don't bail out when the hostname is + overlong, but instead truncate it properly and continue. This fixes + Ubuntu bug #1509081 reported by Sam Reed. + 2015-10-31 Benno Schulenberg * src/nano.c (copy_from_filestruct): When pasting while the mark is on, the mark's pointer needs to be refreshed only when it is on the diff --git a/src/files.c b/src/files.c index 6081e4a1..d2480347 100644 --- a/src/files.c +++ b/src/files.c @@ -143,8 +143,12 @@ int write_lockfile(const char *lockfilename, const char *origfilename, bool modi mypid = getpid(); if (gethostname(myhostname, 31) < 0) { - statusbar(_("Couldn't determine hostname for lock file: %s"), strerror(errno)); - goto free_and_fail; + if (errno == ENAMETOOLONG) + myhostname[31] = '\0'; + else { + statusbar(_("Couldn't determine hostname for lock file: %s"), strerror(errno)); + goto free_and_fail; + } } /* Check if the lock exists before we try to delete it...*/ -- 2.39.5