[Xfce4-commits] [xfce/xfwm4] 01/01: Determine the maximum host name length correctly.

noreply at xfce.org noreply at xfce.org
Fri Nov 7 11:26:01 CET 2014


This is an automated email from the git hooks/post-receive script.

ochosi pushed a commit to branch master
in repository xfce/xfwm4.

commit 19e9cc2db222fde7f138de86f3cedcda4a4d4295
Author: Alistair Buxton <a.j.buxton at gmail.com>
Date:   Wed Nov 5 19:36:11 2014 +0000

    Determine the maximum host name length correctly.
    
    The actual limit on Linux is 64 characters, and on BSD it is 255
    characters. The limit is defined in HOST_NAME_MAX on Posic operating
    systems, so use that definition instead of the one hardcoded into
    Xfwm, and print a warning if it still fails.
    
    Too long hostnames would previously cause the hostname to be set
    to null, which would cause a segfault when terminating a client.
    This patch also adds a null check to that function.
    
    Signed-off-by: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
---
 src/client.c  |    2 +-
 src/display.c |   11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/client.c b/src/client.c
index 60430a8..dc00545 100644
--- a/src/client.c
+++ b/src/client.c
@@ -2573,7 +2573,7 @@ clientTerminate (Client *c)
     screen_info = c->screen_info;
     display_info = screen_info->display_info;
 
-    if ((c->hostname) && (c->pid > 0))
+    if ((c->hostname) && (display_info->hostname) && (c->pid > 0))
     {
         if (!strcmp (display_info->hostname, c->hostname))
         {
diff --git a/src/display.c b/src/display.c
index 00318d5..3c2e7ba 100644
--- a/src/display.c
+++ b/src/display.c
@@ -44,9 +44,9 @@
 #include "client.h"
 #include "compositor.h"
 
-#ifndef MAX_HOSTNAME_LENGTH
-#define MAX_HOSTNAME_LENGTH 32
-#endif /* MAX_HOSTNAME_LENGTH */
+#ifndef HOST_NAME_MAX
+#define HOST_NAME_MAX 255
+#endif /* HOST_NAME_MAX */
 
 #ifndef CURSOR_ROOT
 #define CURSOR_ROOT XC_left_ptr
@@ -313,9 +313,10 @@ myDisplayInit (GdkDisplay *gdisplay)
     display->nb_screens = 0;
     display->current_time = CurrentTime;
 
-    display->hostname = g_new0 (gchar, (size_t) MAX_HOSTNAME_LENGTH);
-    if (gethostname ((char *) display->hostname, MAX_HOSTNAME_LENGTH - 1))
+    display->hostname = g_new0 (gchar, (size_t) HOST_NAME_MAX + 1);
+    if (gethostname ((char *) display->hostname, HOST_NAME_MAX + 1))
     {
+        g_warning ("The display's hostname could not be determined.");
         g_free (display->hostname);
         display->hostname = NULL;
     }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list