diff options
-rw-r--r-- | smproxy.c | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -28,6 +28,11 @@ Author: Ralph Mor, X Consortium #include "smproxy.h" #include <unistd.h> #include <X11/Xmu/WinUtil.h> +#include <limits.h> + +#ifndef HOST_NAME_MAX +#define HOST_NAME_MAX 256 +#endif static XtAppContext appContext; static Display *disp; @@ -210,11 +215,13 @@ CheckFullyQuantifiedName(char *name, int *newstring) } else { - char hostnamebuf[80]; + char hostnamebuf[HOST_NAME_MAX + 1] = { 0 }; char *firstDot; - gethostname (hostnamebuf, sizeof hostnamebuf); - firstDot = strchr (hostnamebuf, '.'); + if (gethostname (hostnamebuf, sizeof hostnamebuf) == 0) + firstDot = strchr (hostnamebuf, '.'); + else + firstDot = NULL; if (!firstDot) { |