X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/8def70c3ec6f81f95673c0de67a75b5a6b2e9e1c..d9e0300f903aa7cfb85a94480ad544082a7a6c35:/unix/ux_x11.c diff --git a/unix/ux_x11.c b/unix/ux_x11.c index 0998069e..5794d315 100644 --- a/unix/ux_x11.c +++ b/unix/ux_x11.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "putty.h" #include "ssh.h" @@ -36,11 +37,14 @@ void platform_get_x11_auth(struct X11Display *disp, const Config *cfg) int len; sfree(disp->hostname); + disp->hostname = NULL; len = 128; do { len *= 2; - disp->hostname = snewn(len, char); - if (gethostname(disp->hostname, len) < 0) { + disp->hostname = sresize(disp->hostname, len, char); + if ((gethostname(disp->hostname, len) < 0) && + (errno != ENAMETOOLONG)) { + sfree(disp->hostname); disp->hostname = NULL; return; }