[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nano-devel
Subject:    Re: [Nano-devel] hostname for locking is sometimes too long
From:       Benno Schulenberg <bensberg () justemail ! net>
Date:       2015-11-05 13:05:43
Message-ID: 1446728743.3918330.429950561.030DFF65 () webmail ! messagingengine ! com
[Download RAW message or body]

On Wed, Nov 4, 2015, at 22:29, Mike Frysinger wrote:
> On 04 Nov 2015 21:53, Benno Schulenberg wrote:
> > On Ubuntu 15.10 we have a serious bug report:
> >   https://bugs.launchpad.net/ubuntu/+source/nano/+bug/1509081
> > 
> > Apparently some hostnames are longer than 31 characters,
> > and gethostname() returns -1 and ENAMETOOLONG.
> > 
> > I think that when this latter error is returned, then
> > write_lockfile() should ignore the -1 return value,
> > null-terminate myhostname, and continue.  Right?
> 
> sounds fine.

Proposed patch is attached.

>  could also increase the 32 to 256.

Well, the hostname is obtained in order to put it into the
vim-style lock file, and there is only a slot of 32 bytes
available for the name, so there is little point in getting
more bytes.

Benno

-- 
http://www.fastmail.com - A fast, anti-spam email service.


["trim-long-hostname.patch" (trim-long-hostname.patch)]

Index: src/files.c
===================================================================
--- src/files.c	(revision 5388)
+++ src/files.c	(working copy)
@@ -136,8 +136,12 @@
     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...*/


_______________________________________________
Nano-devel mailing list
Nano-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/nano-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic