]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Cope with a (non-standard) ENAMETOOLONG return from gethostname(); glibc will
authorJacob Nevins <jacobn@chiark.greenend.org.uk>
Mon, 5 Jan 2009 01:01:58 +0000 (01:01 +0000)
committerJacob Nevins <jacobn@chiark.greenend.org.uk>
Mon, 5 Jan 2009 01:01:58 +0000 (01:01 +0000)
do this if the supplied buffer isn't big enough, which shouldn't lead to
complete abandonment of X11 auth. (Would only have bitten with hostnames
>255 chars anyway.)

[originally from svn r8383]

unix/ux_x11.c

index 0998069e46c2089cab356259485c6b9a0a6c893a..4126d5b7493e1471645376bd62601919191e59c1 100644 (file)
@@ -6,6 +6,7 @@
 #include <unistd.h>
 #include <assert.h>
 #include <stdlib.h>
+#include <errno.h>
 
 #include "putty.h"
 #include "ssh.h"
@@ -40,7 +41,8 @@ void platform_get_x11_auth(struct X11Display *disp, const Config *cfg)
        do {
            len *= 2;
            disp->hostname = snewn(len, char);
-           if (gethostname(disp->hostname, len) < 0) {
+           if ((gethostname(disp->hostname, len) < 0) &&
+               (errno != ENAMETOOLONG)) {
                disp->hostname = NULL;
                return;
            }