summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/winwidget.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/winwidget.c b/src/winwidget.c
index 9495c7f..945c123 100644
--- a/src/winwidget.c
+++ b/src/winwidget.c
@@ -152,8 +152,9 @@ void winwidget_create_window(winwidget ret, int w, int h)
pid_t pid;
int x = 0;
int y = 0;
+ long host_name_max;
char *tmpname;
- char hostname[HOST_NAME_MAX];
+ char *hostname;
D(("winwidget_create_window %dx%d\n", w, h));
@@ -278,11 +279,16 @@ void winwidget_create_window(winwidget ret, int w, int h)
XChangeProperty(disp, ret->win, prop, XA_CARDINAL, sizeof(pid_t) * 8,
PropModeReplace, (const unsigned char *)&pid, 1);
- if (gethostname(hostname, HOST_NAME_MAX) == 0) {
- hostname[HOST_NAME_MAX-1] = '\0';
- prop = XInternAtom(disp, "WM_CLIENT_MACHINE", False);
- XChangeProperty(disp, ret->win, prop, XA_STRING, sizeof(char) * 8,
- PropModeReplace, (unsigned char *)hostname, strlen(hostname));
+ if ((host_name_max = sysconf(_SC_HOST_NAME_MAX)) != -1 ) {
+ if ((hostname = calloc(1, host_name_max + 1)) != NULL ) {
+ if (gethostname(hostname, host_name_max) == 0) {
+ hostname[host_name_max] = '\0';
+ prop = XInternAtom(disp, "WM_CLIENT_MACHINE", False);
+ XChangeProperty(disp, ret->win, prop, XA_STRING, sizeof(char) * 8,
+ PropModeReplace, (unsigned char *)hostname, strlen(hostname));
+ }
+ free(hostname);
+ }
}
XSetWMProtocols(disp, ret->win, &wmDeleteWindow, 1);