From 25a4f913ff8a30a08183dcefcab8f3b69368cb91 Mon Sep 17 00:00:00 2001 From: Alistair Buxton Date: Sun, 9 Nov 2014 17:40:55 +0000 Subject: [PATCH] Ensure hostname is always null terminated. Previous patch introduced a bug on platforms which don't return an error if the hostname is truncated AND don't null terminate the truncated name. Fix this by making the buffer one larger than the namelen passed to gethostname (as it was before the previous patch.) --- src/display.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/display.c b/src/display.c index 3c2e7ba..00bba4f 100644 --- a/src/display.c +++ b/src/display.c @@ -313,7 +313,7 @@ myDisplayInit (GdkDisplay *gdisplay) display->nb_screens = 0; display->current_time = CurrentTime; - display->hostname = g_new0 (gchar, (size_t) HOST_NAME_MAX + 1); + display->hostname = g_new0 (gchar, (size_t) HOST_NAME_MAX + 2); if (gethostname ((char *) display->hostname, HOST_NAME_MAX + 1)) { g_warning ("The display's hostname could not be determined."); -- 1.9.1