From 205769d4ecbc5f76b327524a0a1796ef91780089 Mon Sep 17 00:00:00 2001 From: Alistair Buxton Date: Sun, 9 Nov 2014 19:28:37 +0000 Subject: [PATCH] Go back to MAX_HOSTNAME_LENGTH Platform specific values for MAX_HOSTNAME_LENGTH could be generated via autoconf tests, which should be more reliable and able to deal with more different platforms than just using HOST_NAME_MAX directly. Therefore, instead of using HOST_NAME_MAX, just increase the default for MAX_HOSTNAME_LENGTH so that it is enough for all known platforms. The default now also corresponds to the Xorg _XGetHostname implementation, which always uses a 256 char array. However, keep the null check and the warning from previous commit. For more information see: https://bugzilla.xfce.org/show_bug.cgi?id=11282 https://bugzilla.xfce.org/show_bug.cgi?id=11289 --- src/display.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/display.c b/src/display.c index 3c2e7ba..799a2cc 100644 --- a/src/display.c +++ b/src/display.c @@ -44,9 +44,9 @@ #include "client.h" #include "compositor.h" -#ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 255 -#endif /* HOST_NAME_MAX */ +#ifndef MAX_HOSTNAME_LENGTH +#define MAX_HOSTNAME_LENGTH 256 +#endif /* MAX_HOSTNAME_LENGTH */ #ifndef CURSOR_ROOT #define CURSOR_ROOT XC_left_ptr @@ -313,8 +313,8 @@ myDisplayInit (GdkDisplay *gdisplay) display->nb_screens = 0; display->current_time = CurrentTime; - display->hostname = g_new0 (gchar, (size_t) HOST_NAME_MAX + 1); - if (gethostname ((char *) display->hostname, HOST_NAME_MAX + 1)) + display->hostname = g_new0 (gchar, (size_t) MAX_HOSTNAME_LENGTH); + if (gethostname ((char *) display->hostname, MAX_HOSTNAME_LENGTH - 1)) { g_warning ("The display's hostname could not be determined."); g_free (display->hostname); -- 1.9.1