HOST_NAME_MAX is sanctioned by POSIX.
drop 37-gnu-hurd.patch: already applied / other fix here
+++ /dev/null
-Description: Further fixes to the build on the GNU Hurd
- - include <sys/file.h> for LOCK_EX
- - define MAXHOSTNAMELEN if absent
-Forwarded: no
-Author: Peter Pentchev <roam@ringlet.net>
-Last-Update: 2010-10-16
-
---- a/spool.c
-+++ b/spool.c
-@@ -32,6 +32,7 @@
- * SUCH DAMAGE.
- */
-
-+#include <sys/file.h>
- #include <sys/stat.h>
-
- #include <ctype.h>
---- a/util.c
-+++ b/util.c
-@@ -33,6 +33,7 @@
- */
-
- #include <sys/param.h>
-+#include <sys/file.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <netdb.h>
-@@ -43,6 +44,14 @@
-
- #include "dma.h"
-
-+/**
-+ * A quick'n'dirty hack to get dma to build on the GNU Hurd.
-+ * A real fix would dynamically allocate the hostname array.
-+ */
-+#ifndef MAXHOSTNAMELEN
-+#define MAXHOSTNAMELEN 1024
-+#endif
-+
- const char *
- hostname(void)
- {
const char *
hostname(void)
{
- static char name[MAXHOSTNAMELEN+1];
+ static char name[HOST_NAME_MAX+1];
static int initialized = 0;
if (initialized)
local:
if (gethostname(name, sizeof(name)) != 0)
strcpy(name, "(unknown hostname)");
+ /*
+ * gethostname() is allowed to truncate name without NUL-termination
+ * and at the same time not return an error.
+ */
+ name[sizeof(name) - 1] = 0;
initialized = 1;
return (name);
}